Not enough input arguments for the size function of a matrix

5 views (last 30 days)
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?

Accepted Answer

L
L on 2 Jul 2013
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.

More Answers (1)

Walter Roberson
Walter Roberson on 1 Jul 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 Comment
Walter Roberson
Walter Roberson on 2 Jul 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)

Sign in to comment.

Categories

Find more on Resizing and Reshaping Matrices in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!