creating a matrix with different vector length using a loop

5 visualizzazioni (ultimi 30 giorni)
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

Risposta accettata

Walter Roberson
Walter Roberson il 11 Ago 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

Più risposte (0)

Categorie

Scopri di più su Loops and Conditional Statements in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by