MATLAB Answers

How to multiply only some column and rows for a given number?!

2 views (last 30 days)
Myke Ziz
Myke Ziz on 2 Jan 2020
Commented: Fabio Freschi on 2 Jan 2020
I want to multiply for 2.5 the all the rows (2 in total) but not the 1 column, how should I do?
Like this I litterally get rid of the column 1 after multiplying for 2.5.
scores = score(1:2,2:21).*(2.5)
Thank you for you help
Best

  0 Comments

Sign in to comment.

Answers (1)

Fabio Freschi
Fabio Freschi on 2 Jan 2020
You are close to the answer, but you need to keep the first column
% your matrix with data
A = rand(2,21);
% multiply all but the first column
B = [A(:,1) A(:,2:end)*2.5];

  2 Comments

Myke Ziz
Myke Ziz on 2 Jan 2020
Thank you a lot Fabio for your great answer it is clear now!!
Best regards
Z.M.
Fabio Freschi
Fabio Freschi on 2 Jan 2020
My pleasure! Please accept the answer if it solves your original problem
F

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!