Not enough input arguments for the size function of a matrix
Mostrar comentarios más antiguos
function [Q, R] = htfqr(A)
%Householder triangularization
[m, n] = size(A);
for k = 1:n;
x = A(k:m,k);
x(1) = x(1) + sign(x(1))*norm(x);
v = x/norm(x);
A(k:m,k:n) = A(k:m,k) - 2*v*(v'*A(k:m,k));
x(k:m) = x(k:m) - 2*v*(v'*x(k:m));
end
R = A(k:m, k:n)
Q = x(k:m)
When I try to run it, it keeps sending the message that there is not enough input arguments for the 3rd line, which is nothing more than the size of A.
I kept saving the changes and deleting it from the documents, then saving the script again, but it keeps sending me that error message. What is the problem?
Respuesta aceptada
Más respuestas (1)
Walter Roberson
el 1 de Jul. de 2013
You have somehow invoked the routine without passing in a value for A.
How are you invoking the routine? You cannot start this routine by pressing F5 or clicking on Run in the menus. You must go to the command line and give the command htfq and pass in your input. For example at the command line,
htfq(rand(11,17))
1 comentario
Walter Roberson
el 2 de Jul. de 2013
How are you invoking the routine? You cannot just define "A" at the command line and then run your htfq and expect that it will fetch "A" from its previous definition. Whatever value you want for your "A" matrix must be passed in to the routine, such as
MyMatrix = [1:20;78:97;-10*pi:19-10*pi];
htfq(MyMatrix)
Categorías
Más información sobre Resizing and Reshaping Matrices en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!