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!