Repeat calculation 24 times (Cell arrays)
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
RP
am 7 Apr. 2025
Beantwortet: Walter Roberson
am 7 Apr. 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 Kommentar
Walter Roberson
am 7 Apr. 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);
Akzeptierte Antwort
Walter Roberson
am 7 Apr. 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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Multidimensional Arrays finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!