MATLAB Answers


vector addition in a single row

Asked by PK
on 28 Sep 2012

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 Comment

Please post what you have tried so far and which problems occurred.


No products are associated with this question.

1 Answer

Answer by Sabarinathan Vadivelu on 28 Sep 2012
 Accepted answer

w = 2;
N = 10; % N value may be anything as the length u need..
for i = 1 : N

  1 Comment

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.

Join the 15-year community celebration.

Play games and win prizes!

Learn more
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!