vector addition in a single row

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일

0 개 추천

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개)

카테고리

도움말 센터 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by