Repeat calculation 24 times (Cell arrays)

1 回表示 (過去 30 日間)
RP
RP 2025 年 4 月 7 日
回答済み: Walter Roberson 2025 年 4 月 7 日
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 件のコメント
Walter Roberson
Walter Roberson 2025 年 4 月 7 日
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);

サインインしてコメントする。

採用された回答

Walter Roberson
Walter Roberson 2025 年 4 月 7 日
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 件)

カテゴリ

Help Center および File ExchangeMultidimensional Arrays についてさらに検索

タグ

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by