How to Add Multiple Arrays?
古いコメントを表示
I am new to matlab. I want to do the following: I had created nine arrays and gave each one a name from A to I, said: A,B,C,D,E,F,G,H,I. Once I done that what I want to do is add them in groups of three and put to each new array the name of the last array added. For example. array C=A+B+C, array F=D+E+F, array I=G+H+I, I want to do this using a for loop which I think will be the most practical way of do it.
Thank you
採用された回答
その他の回答 (2 件)
Andrew Newell
2011 年 3 月 19 日
It's not clear to me why you want loops. As long as the arrays are the same size, you can just enter the equations the way you wrote them above, e.g.,
C = A+B+C
and it will work.
9 件のコメント
Doralee
2011 年 3 月 19 日
Doralee
2011 年 3 月 19 日
Andrew Newell
2011 年 3 月 19 日
So how are all these matrices named? You'll run out of letters pretty fast.
Andrew Newell
2011 年 3 月 19 日
And how are you generating them? Are you reading them from a file or getting them from some other calculation?
Doralee
2011 年 3 月 19 日
Oleg Komarov
2011 年 3 月 19 日
You should use a cell array or a structure.
If the satellite data for each day is a vector/matrix you could combine it into a single double matrix/3d array (padding with NaN where necessary). That "could" be optimal.
In order to help you we should start from the format of the data as it is stored in files.
Doralee
2011 年 3 月 19 日
Doralee
2011 年 3 月 19 日
Doralee
2011 年 3 月 19 日
Sean de Wolski
2011 年 3 月 19 日
doc cat
doc sum
2 件のコメント
Doralee
2011 年 3 月 19 日
Matt Tearle
2011 年 3 月 19 日
When you say "alternatively", do you mean "columns rather than rows" or "alternating columns"?
Former: sum(A,2)
Latter: sum(A(:,1:2:end))
カテゴリ
ヘルプ センター および 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!