Error: Not enough input argument (line 6)
Ältere Kommentare anzeigen
Why do I get this error message when running following script?
function outtype = findargtype (inputarg)
% findargtype determines whether the input
% argument is a scalar,vector, or matrix
% format of call: findargtype(inputArgument)
% Returns a string
[r c] = size (inputarg) ;
if r== 1 && c== 1
outtype='scalar';
elseif r== 1 || c== 1
outtype='vector';
else
outtype='matrix';
end
end
2 Kommentare
Star Strider
am 23 Aug. 2012
How are you calling your function findargtype from your main script? What are you giving it for inputarg as an argument?
Walter Roberson
am 23 Aug. 2012
Your code does not react consistently to empty inputs. The [] construct is 0 by 0 and so would show up as 'matrix' in your tests, but zeros(0,1) would show up as vector.
Please also try this test:
[r c] = size(zeros(0,1,2))
and
[r c] = size(zeros(1,0,2))
size() does not do what you think it does.
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Creating and Concatenating Matrices finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!