Repeat calculation 24 times (Cell arrays)
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
RP
le 7 Avr 2025
Réponse apportée : Walter Roberson
le 7 Avr 2025
I have to repeat a calculation 24 times and store the results. I have written the code for the first column. How do I repeat it 24 times for each column.
p=[0.1,0.5,1,2.5,5,10,25,50,75,90,95,97.5,99,99.5,99.9];
for i=1:50
for j=1:500000
stress(j,i)=E(i,1)*D(j,1);
end
end
for k=1:15
for i=1:50;
Stressperc(k,i)=prctile(stress(:,i),p(1,k));
end
end
1 commentaire
Walter Roberson
le 7 Avr 2025
Note that more efficient would be
p=[0.1,0.5,1,2.5,5,10,25,50,75,90,95,97.5,99,99.5,99.9];
for i=1:50
stress(:,i) = E(i,1) .* D(:,1);
end
Stressperc = prctile(stress, p);
Réponse acceptée
Walter Roberson
le 7 Avr 2025
p=[0.1,0.5,1,2.5,5,10,25,50,75,90,95,97.5,99,99.5,99.9];
Stressperc = zeros(numel(p), 50, 24);
for col = 1 : 24
for i=1:50
stress(:,i) = E(i,1) .* D(:,col);
end
Stressperc(:,:,col) = prctile(stress, p);
end
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Multidimensional Arrays 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!