Saving a file name in a matrix and the result on each iteration (for-loop)

1 view (last 30 days)
I have a folder with 140 (*. Txt) files and I need save in a matrix these files names and the result of the process in a for-loop. I have tried this:
% code
class= fullfile('*.txt');
D = dir(class);
data=zeros(length(D),2);
for kk=1:length(D);
blockname = D(kk).name;
%process > result(kk);
data(kk,1)=result(kk);
data(kk,2)= blockname;
end
but the next error message is displayed
data(kk,2)= blockname; ??? Subscripted assignment dimension mismatch.
Because
>> blockname
blockname =
block_100.txt
I do not have idea how solve it. Thanks in advance for your help.

Accepted Answer

the cyclist
the cyclist on 17 Dec 2015
Try using a cell array instead of a numeric matrix.

More Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!