creating a matrix with different vector length using a loop

4 vues (au cours des 30 derniers jours)
Paola
Paola le 11 Août 2021
Commenté : Paola le 17 Août 2021
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

Réponse acceptée

Walter Roberson
Walter Roberson le 11 Août 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

Plus de réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by