creating a matrix with different vector length using a loop

5 次查看(过去 30 天)
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

采纳的回答

Walter Roberson
Walter Roberson 2021-8-11
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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by