vector addition in a single row
1 次查看(过去 30 天)
显示 更早的评论
for a constant w=2 a matrix is to be generated by incrementing it as many times and save it in another matrix as the following way out=[w+1 w+2 w+3 w+4.......]
采纳的回答
Sabarinathan Vadivelu
2012-9-28
w = 2;
N = 10; % N value may be anything as the length u need..
for i = 1 : N
out(i)=[w+i];
end
1 个评论
Jan
2012-9-28
Please do not answer homework questions.
A pre-allocation would be more efficient. Otherwise "out" grows in each iteration, which wastes a lot of time - for larger arrays.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!