compile script to create program
Ältere Kommentare anzeigen
Hi
I've made made a script that is able to sort my "list2.csv" and then put it into a table. This list2.csv was only the test list. Now i need to change my script so it is possible to use it as a function on any list(with same amount of columns) that is put into it. can You guys please help me.
THX!!
7 Kommentare
Jan
am 10 Apr. 2017
All you need is to use a variable instead of a ficed file name. But without seeing the code it is impossible to suggest explicite changes.
Anne
am 10 Apr. 2017
Adam
am 10 Apr. 2017
Just put
function myFunction( filename )
at the top and remove the first line, then call it as e.g.
myFunction( 'C:\Users\PET-Center\Documents\MATLAB\KFList.csv' )
though call it something more sensible - it needs to be the same as your file name in which the code sits.
Anne
am 10 Apr. 2017
Anne
am 10 Apr. 2017
Adam
am 10 Apr. 2017
Don't change the second line, put that (though again, use a sensible name) as the first line and remove the current first line. The function signature has to be the first thing in the file.
Anne
am 11 Apr. 2017
Antworten (1)
function myfun(filename)
%
delimiter = ',';
startRow = 2;
... the rest of your code.
end
And then call it using:
myfun( 'C:\Users\PET-Center\Documents\MATLAB\KFList.csv' )
Kategorien
Mehr zu Text Files finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!