Do you know how can I fix this error? "Not enough input arguments" Thanks

function r = rank(A,tol)
%RANK Matrix rank.
% RANK(A) provides an estimate of the number of linearly
% independent rows or columns of a matrix A.
% RANK(A,tol) is the number of singular values of A
% that are larger than tol.
% RANK(A) uses the default tol = max(size(A)) * eps(norm(A)).
s = svd(A);
if nargin==1
tol = max(size(A)) * eps(max(s));
end
r = sum(s > tol);
>>>Error using rank (line ) Not enough input arguments<<>> s = svd(A); <<<
My matrix is A=[1 4 3 7 ; 2 6 8 3 ; 1 3 4 5 ; 4 13 15 15] And I am trying to calculate rank of A.

 Accepted Answer

How are you calling it?
Are you including a value for ‘tol’ as your function requires?

10 Comments

That is exactly the code for the built-in MATLAB rank function. Please do not create your own versions of built-in MATLAB functions and save them with the same name as the original.
This runs for me without error:
Arank = rank(A)
producing:
Arank =
3
meaning that one row or column is linearly dependent.
But I have to use MATLAB function to show that the rank of A is three.
If you use the code I posted, you just did.
To use a MATLAB function does not imply that you have to copy it to a different function file — just use it as it exists.
Sorry :) Can you help me with this code. I want not to display "ans=0". Semicolon does not work. thanks
function y=davaleba(a);
a=input( ' matrix: ' ) % MATRIX IS [1 4 3 7; 2 6 8 3;1 3 4 5; 4 13 15 15];
y=det(a);
end
Plz can you run this command? and insert this matrix which I mentioned above. Determinant is zero and it displays in command window which I do not want, I used semicolon for that. still does not work
When I run the det function with it independently, the deteminant is 0.
If you don’t want it displaying in the Command Window, you have to put the semicolon after the call to the function:
y=davaleba(a);
The semicolon after the first line of the function itself does nothing.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!