how to fill matrix without using for loop?
5 ビュー (過去 30 日間)
古いコメントを表示
a=zeros(24,4); b=ones(24,1);
Why does not this work?
a(:,1:end)=b(:)
Subscripted assignment dimension mismatch.
Does anyone know where I am going wrong? bold
0 件のコメント
採用された回答
その他の回答 (2 件)
Wayne King
2013 年 11 月 11 日
編集済み: Wayne King
2013 年 11 月 11 日
because b isn't the right size. b is 24x1 but you are trying to fill all 4 columns of a
How about just
a = ones(24,4);
or if you really want to "fill" starting with zeros.
a = zeros(24,4);
b = ones(24,1);
b = repmat(b,1,4);
a = b;
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!