fopen function how to use a variable name to select a file present in a folder?
Show older comments
i have some csv files in a folder which i am trying to edit using matlab.
my code is below
yourfolder='D:\practice\Matlab\APM3 magnet measurements\Sensormagnet1';
d=dir([yourfolder '\*.csv']);
files={d.name};
file=files(1);
fid = fopen(file,'w');
files is a variable which has list of csv files present in folder. i created a variable to get one file name out of the list and trying to open the file with the name present in the file variable.
its giving error as given below:
Error using fopen
First input must be a file name of type char, or a file identifier of type double.
Error in CSV (line 5)
fid = fopen(file,'w');
please help me on this
Accepted Answer
More Answers (0)
Categories
Find more on Software Development Tools in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!