MATLAB Answers

Multiply a column by a number

284 views (last 30 days)
Elaheh
Elaheh on 30 Mar 2018
Answered: Roger Stafford on 30 Mar 2018
How Could I simply multiply each element of this array by 4? A=array(:,6);

  0 Comments

Sign in to comment.

Accepted Answer

David Fletcher
David Fletcher on 30 Mar 2018
A=A.*4

  0 Comments

Sign in to comment.

More Answers (1)

Roger Stafford
Roger Stafford on 30 Mar 2018
Let Ar be the name of the array.
Ar(:,6) = 4*Ar(:,6);
What could be simpler? Since 4 is a scalar, it is automatically applied to each element of that column.

  0 Comments

Sign in to comment.

Sign in to answer this question.


Translated by