Repeat calculation 24 times (Cell arrays)

1 view (last 30 days)
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 Comment
Walter Roberson
Walter Roberson on 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);

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 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

More Answers (0)

Categories

Find more on Multidimensional Arrays in Help Center and File Exchange

Products


Release

R2022a

Community Treasure Hunt

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

Start Hunting!