help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Vectorizing diagonalization of multiple matrices


From: Nicholas Jankowski
Subject: Re: Vectorizing diagonalization of multiple matrices
Date: Tue, 5 May 2020 20:29:50 -0400

Currently I am constructing and diagonalizing the matrices with for loops:
x = linspace(0,1,5);
y = linspace(2,3,5);
for u=1:5
for v=1:5
M = [ y(v)*x(u) , x(u) ;  x(u) , -y(v)^2 ];
[vecs(:,:,u,v),vals (:,:,u,v)] = eig(M(:,:,u,v));
end
end

currently that code errors out for me:

parse error near line 6 of file C:\Users\nicholas.jankowski\Desktop\temp\test.m

  syntax error

>>>     [vecs(:,:,u,v),vals (:,:,u,v)] = eig(M(:,:,u,v));

if I delete the space between "vals ("  :
x = linspace(0,1,5);
y = linspace(2,3,5);
for u=1:5
for v=1:5
M = [ y(v)*x(u) , x(u) ;  x(u) , -y(v)^2 ];
[vecs(:,:,u,v), vals(:,:,u,v)] = eig(M(:,:,u,v));
end
end

then I get:
error: M(_,_,_,2): but M has size 2x2
error: called from
    test at line 6 column 36

reply via email to

[Prev in Thread] Current Thread [Next in Thread]