creating a matrix with different vector length using a loop

5 views (last 30 days)
Hi,
I would like to create a matrix with different vectors that have different lengths (I take this vectror from a filelist), and I would like to do it using a loop. I alredy wrote this part of the code but it doesn' work. can someone help me with this? thanks
lfl=length(filelist)
for ii=1:lfl
ii
load([filelist(ii).name],'dist_pre','A_fin_mean')
distpret(ii)=dist_pre
A_fin_mean(ii)=A_fin_mean
end

Accepted Answer

Walter Roberson
Walter Roberson on 11 Aug 2021
lfl=length(filelist);
distpret = cell(lfl, 1);
A_fin_mean = cell(ifl, 1);
for ii=1:lfl
data = load(filelist(ii).name,'dist_pre','A_fin_mean')
distpret{ii} = data.dist_pre;
A_fin_mean{ii} = data.A_fin_mean;
end

More Answers (0)

Categories

Find more on Loops and Conditional Statements 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!