simple way to multiply varying parameter with matrice

조회 수: 1 (최근 30일)
steffen seligmann
steffen seligmann 2020년 9월 23일
답변: Ameer Hamza 2020년 9월 23일
Hello,
My goal is to to diag() my matrice and then plot the eigenvalues over the parameter. since both *, .* are not helpful in this situation is there any very simple way to archieve my goal without having to use any for loops or such?
  댓글 수: 3
steffen seligmann
steffen seligmann 2020년 9월 23일
like, i have a parameter param = 0:0.1:2 and matrice A. Now i want to do sth like multiply each element of param with A and diag() the resulting matrice B to then plot(param,B) for each element of param.
madhan ravi
madhan ravi 2020년 9월 23일
What ? size(A) ?

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

채택된 답변

Ameer Hamza
Ameer Hamza 2020년 9월 23일
Try this
A = rand(2,2);
param = 0:0.1:2;
M = arrayfun(@(x) {x*A}, param);
M = blkdiag(M{:});
It multiplies A with all values in param and places the output on diagonals of matrix M.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Red에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by