MATLAB: Subscripted assignment dimension mismatch.

dimension mismatcheigs

Hello, I am relatively new to matlab and it's function handle approach.
I am trying to calculate the largest eigenvalue of a very large sparse matrix for which I only have a function. My code looks something like this (the part where the error occurs):
function s=my_function(A)
hand=@(x) Multiply_by_Ar(A,x);
s=eigs(hand,1);
The function Multiply_by_Ar returns, for a given A and x, the vector Ar*x, where the matrix Ar is related to A, but not equal to it. I then make a function handle which is basically multiplying by Ar and use the eigs function. It returns the problem
??? Subscripted assignment dimension mismatch.
Error in ==> eigs>fullEig at 1188
AA(:,i) = A(AA(:,i),varargin{afunNargs});
Error in ==> eigs at 104
fullEig(nargout);
Error in ==> s_radij_SOR at 6
s=eigs(rocka,1);
Which I do not understand. Please help.

Best Answer

  • Your traceback does not correspond to the code you show. Your code shows my_function invoking eigs() with "hand" as its first argument, but the traceback shows function s_radij_SOR invoking eigs() with "rocka" as its first argument.