'Unexpected output' error using SVDS with function handle

14 Ansichten (letzte 30 Tage)
Jeremy Myers
Jeremy Myers am 10 Okt. 2018
Bearbeitet: Christine Tobler am 10 Okt. 2018
I need to pass a function handle, which performs a matrix-vector multiplication, to SVDS. I have
[U,S,V] = svds( @(x,tflag) denseSparseMatvec(X, 'notransp', B1, B2), [m n], k);
where the output of denseSparseMatvec is m x n and I want the k largest singular values. I get the error
Unexpected output of function handle with flag 'notransp'. The expected output is a column
vector of length 20 and of type double.
If, as a test, I simply do M = denseSparseMatvec(X, 'notransp', B1, B2) and then [U,S,V] = svds(M, k), everything works fine.
What's going on here?

Antworten (1)

Christine Tobler
Christine Tobler am 10 Okt. 2018
Bearbeitet: Christine Tobler am 10 Okt. 2018
Maybe the problem is that you use both x and X in the definition of the anonymous function? A matrix X in your workspace would be used every time, while the vector x that SVDS passes in is ignored.
Also, the function handle passed to SVDS must compute M*x if the input tflag is 'notransp', and compute M'*x if it is 'transp'.

Kategorien

Mehr zu Eigenvalues finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by