Effacer les filtres
Effacer les filtres

Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

Could anyone help me how to multiply the second and third element of the row in a matrix by an value of 2 and 3.

1 vue (au cours des 30 derniers jours)
jaah navi
jaah navi le 21 Fév 2020
Clôturé : MATLAB Answer Bot le 20 Août 2021
I am having the matrix A=[ 2 3 4]
I want to multiply the second element by 2 and third element by 3.
could anyone please help me on this.

Réponses (1)

Sindar
Sindar le 21 Fév 2020
A=[ 2 3 4];
A(2) = A(2)*2;
A(3) = A(3)*3;
More generally, you can use elementwise multiplication:
A=[ 2 3 4 5 6 7 8];
A = A.*[1:7];
Also, this is a great resource for starting out in Matlab: https://www.mathworks.com/company/newsletters/articles/matrix-indexing-in-matlab.html

Cette question est clôturée.

Community Treasure Hunt

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

Start Hunting!

Translated by