adjust for matrix input
1 回表示 (過去 30 日間)
古いコメントを表示
How do I in a spimple way adjust this below to be able to handle a matrix as input, for example if:
p_t2=rand(2,1000)
pt2=rand(2,40)
JJ=[];
for z=1:40
for v=1:25
XX=p_t2(v)./pt2;
JJ=[JJ sum(XX)];
end
p_t2(1:25)=[];
pt2(:,1)=[];
end
I want the output JJ be a matrix with dimension (2,1000)
0 件のコメント
回答 (1 件)
Azzi Abdelmalek
2013 年 6 月 5 日
編集済み: Azzi Abdelmalek
2013 年 6 月 5 日
Use sum(XX,2) instead of sum(XX)
p_t2=rand(2,1000);
pt2=rand(2,40);
JJ=[]
for z=1:40
for v=1:25
XX=p_t2(v)./pt2;
JJ=[JJ sum(XX,2)];
end
p_t2(1:25)=[];
pt2(:,1)=[];
end
3 件のコメント
Jan
2013 年 6 月 5 日
So, Lukas, I suggest that you explain what you want to calculate. We cannot guess it.
参考
カテゴリ
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!