MATLAB Answers

Can anybody help me?

조회 수: 2(최근 30일)
Tiziano Bagnasco
Tiziano Bagnasco 28 Oct 2020
답변: madhan ravi 28 Oct 2020
Good morning everyone,
I'm not really into Matllab and that's why I'm asking you to help me. I'm trying to create a for loop in which i multiply a matrix P by a scalar( the ith component of lambda) that changes for evey iteration. So i want to repeat this operation 19 times.
To be more clear:
lambda= 0.1:0.05:1; lambda is a row vector (1x19 double)
The matrix P is a 13x13 double
I began with something like this but I don't know how to continue:
for i=1:length(lambda)
Pprime(i) = P.*(lambda)
end
Thanks in advance

  댓글 수: 0

댓글을 달려면 로그인하십시오.

답변(2개)

Alan Stevens
Alan Stevens 28 Oct 2020
Change
Pprime(i) = P.*(lambda)
to
Pprime(i) = P.*(lambda(i));

  댓글 수: 0

댓글을 달려면 로그인하십시오.


madhan ravi
madhan ravi 28 Oct 2020
Pprime = bsxfun(@times, P, reshape(lambda, 1, 1, [ ]) % for newer versions use .* directly

  댓글 수: 0

댓글을 달려면 로그인하십시오.

태그

Community Treasure Hunt

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

Start Hunting!

Translated by