how can I loop inside a folder that has several files and put each inside a cell column.I tried the code below it retrieves the first file and places it inside several cell columns.how could I modify it so that it does it for each file instead?thanks

1 view (last 30 days)
for k=1:numfiles
mydata{k}=File_path(k).name;
gendat=mydata{k};
gen=strcat(file_path,gendat);
fid=fopen(gen);
mydat{k}=textscan(fid,'%s','delimiter','\n');
mydat{k}=mydat{1,1};
final_data{k}=mydat{1,k}{1,1};
temp=final_data{k};
flag_1=temp{1};
Indx1=strfind(flag_1,'No');
if (~isempty(Indx1))
continue;
else
myfinal_data{k}=temp;
end
fclose(fid);
end

Accepted Answer

Star Strider
Star Strider on 4 Jul 2015
I can’t run your code, so I can’t be certain, but it seems to me that one possible solution is to eliminate this line:
mydat{k}=mydat{1,1};
It seems that would overwrite every subsequent file read by assigning the first cell to all of them.

More Answers (0)

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!