Problem with the mean of index
2 ビュー (過去 30 日間)
古いコメントを表示
% tr(i,j,ni) is 361*361*432
t_r = zeros(361,361,35);
ind=10:16;
for t=1:(ni/12)-1;
if t<=34
* *mean_tr* = mean(tr(i,j,ind));*
t_r(i,j,t) = mean_tr;
ind = ind + 12;
else
end
end
mean_winter_sid = mean(t_r,3);
4 件のコメント
Star Strider
2016 年 3 月 30 日
Could it possibly be that:
mean(tr(i,j,ind))
are zero?
For example:
q = mean([-3:3])
q =
0.0000e+000
採用された回答
Azzi Abdelmalek
2016 年 3 月 30 日
You can calculate the mean without a for loop
A=rand(361,361,432);
mina=mean(A(:)) % the mean off all the matrix
min1=mean(A,1); % dimension 1
min2=mean(A,2); % dimension 2
min3=mean(A,3); % dimension 3
4 件のコメント
その他の回答 (1 件)
Chad Greene
2016 年 3 月 30 日
Do the values of indices i and j ever change?
Can you describe in words what you are trying to do? I have a feeling it can be done much more simply and efficiently without loops.
参考
カテゴリ
Help Center および File Exchange で Loops and Conditional Statements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!