multiplying row vector by a scalar
이전 댓글 표시
trying to multiply the third row of a matrix by another row, B:
A = data(3, ;).*B
where B is a row vector
Need help finding a way to multiply the 3rd row of my matrix by a scalar value, for example 100.
Is there a way to do this all in one line?
Thanks!
답변 (4개)
the cyclist
2023년 2월 23일
You needed a colon in place of that semicolon
A = data(3,:).*B
댓글 수: 3
Kay
2023년 2월 23일
John D'Errico
2023년 2월 23일
They both told you how to do EXACTLY that. Did you try it?
Kay
2023년 2월 23일
A = ones(4,3)
B = 1:3;
A(3,:) = A(3,:).*B
% Your matrix
M = magic(4)
% Your scalar
scalar = 100;
% Multiply the third row of your matrix by your scalar
M(3,:) = scalar .* M(3,:)
카테고리
도움말 센터 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!