Not enough input arguments for the size function of a matrix

Asked by L about 11 hours ago
Latest activity Commented on by Walter Roberson about 4 hours ago
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?

0 Comments

L

Products

2 Answers

Answer by L about 6 hours ago
Accepted answer

Ah, like defining A?

I did input a small 3x3 matrix when attempting to run it, but it told me there were "not enough input arguments". The only thing the third line is supposed to do is get the dimensions so that it can plug in the values below. I looked at the "rand" function, and it is used to return a matrix, which is not necessary in this case, or is it?

Sorry; I'm new to MATLAB...and programming. Thank you for the feedback.

0 Comments

L
Answer by Walter Roberson about 11 hours ago

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 Comment

Walter Roberson about 4 hours ago

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)
Walter Roberson

Contact us