simple way to multiply varying parameter with matrice

1 Ansicht (letzte 30 Tage)
steffen seligmann
steffen seligmann am 23 Sep. 2020
Beantwortet: Ameer Hamza am 23 Sep. 2020
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 Kommentare
steffen seligmann
steffen seligmann am 23 Sep. 2020
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 am 23 Sep. 2020
What ? size(A) ?

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Ameer Hamza
Ameer Hamza am 23 Sep. 2020
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.

Weitere Antworten (0)

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by