Creating a Function
Ältere Kommentare anzeigen
This may be a rather simple question for some but I am new to Matlab. I have written a function (in the process of automating a job) to use textscan to import some data prior to processing. I have a function that seems to work fine as a script, but for the function I've allowed the passing of a parm (FileName) so that I can go through and import multiple files. When I call the function it completes just fine, however there are no variables available in my workspace to be referenced for analysis. My Function is written as follows.
function ImportReturns2(MyFile)
%Create a connection to the file
FileToOpen = fopen(MyFile)
%Import the Returns Data using TextScan
MyData = textscan(FileToOpen, '%s %s %n','Delimiter',',')
%Close Connection to the File
fclose(FileToOpen)
end
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Variables finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!