フィルターのクリア

vector addition in a single row

2 ビュー (過去 30 日間)
PK
PK 2012 年 9 月 28 日
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.......]
  1 件のコメント
Jan
Jan 2012 年 9 月 28 日
Please post what you have tried so far and which problems occurred.

サインインしてコメントする。

採用された回答

Sabarinathan Vadivelu
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
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 件)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by