how to store the matrix from for loop?
古いコメントを表示
m=3;
A=[ 1 1 0];
B=[0 1 0];
D=B-A;
d1=m*A;
for X=0:1:m
C=d1+D*X
end
採用された回答
その他の回答 (1 件)
Andrei Bobrov
2017 年 2 月 1 日
編集済み: Andrei Bobrov
2017 年 2 月 2 日
m=3;
A=[ 1 1 0];
B=[0 1 0];
D=B-A;
d1=m*A;
C = d1 + (0:m)'*D; % R2016b and later
C = bsxfun(@plus,d1,(0:m)'*D); % R2016a and earlier
2 件のコメント
Stephen23
2017 年 2 月 2 日
+1 nice use of MATLAB.
Andrei Bobrov
2017 年 2 月 2 日
Thank you Stephen!
カテゴリ
ヘルプ センター および File Exchange で Creating and Concatenating Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!