In an assignment A(I) = B, the number of elements in B and I must be the same.
2 ビュー (過去 30 日間)
古いコメントを表示
why is this giving an error...!
A1=[2 1];
>> for i=1:2;
A(k)=[-1 1];
A(k+1)=A1+A(k);
end
1 件のコメント
回答 (2 件)
Thorsten
2015 年 10 月 29 日
You cannot assign a 1x2 matrix [-1 1] to a single element A(k) of a matrix.
It is not clear to me what you want to achieve with these lines. Note that your loop uses i, but i is never used in the loop.
0 件のコメント
Eng. Fredius Magige
2015 年 10 月 29 日
A1=[]; >> for i=1:2; i=i A1(1,1)=i.*-1 A1(1,2)=1 %k==i, you mean that A1=[A1; []] % or you mean this A1' end
0 件のコメント
参考
カテゴリ
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!