MATLAB Answers


vector matrix multiplication with increment

Asked by PK
on 28 Sep 2012

for a constant incremental of +1 the out result is to be multiplied and stored in another matrix ex: A=[1 2 3 4 5] and W=4 so the result is to be as OUT=[1*W 2*(W+1) 3*(W+3) 4*(W+4) 5*(W+5)] addition to occur first and then multiplication can u help in this.

  1 Comment

on 28 Sep 2012

Is this homework?


No products are associated with this question.

2 Answers

Answer by Sabarinathan Vadivelu on 28 Sep 2012

W = 4;
A = [1 2 3 4 5];
n = numel(A);
for i = 1 : n
    out(i) = [A(i)*(W+i)];


Answer by Andrei Bobrov
on 28 Sep 2012

out = A.*(W + A)


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!