'Not Enough Input Arguments" error in IF statement

17 views (last 30 days)
I seem to be have an issue with my function, where I would get this error, Heres my code;
The error occurs in [ If (N <10000 ], where it says 'Not Enough Input Arguements. I dont understand, its supposed to be only one variable.
function SmB = Big(N)
%SArranges a number in ascending order
NUMARR= zeros(1,4);
if (N <10000 )
Fourth = mod(N,10);
Third = ( mod(N,100) - (mod(N,10)))/10;
Second = ( mod(N,1000) - (mod(N,100)) )/100;
First = ( mod(N,10000) - (mod(N,1000)) )/1000;
elseif (N<1000) % 3 digit number
First = 0;
Fourth = mod(N,10);
Third = ( mod(N,100) - (mod(N,10)))/10;
Second = ( mod(N,1000) - (mod(N,100)) )/100;
elseif( N<100) %2 digit
First = 0;
Second = 0;
Fourth = mod(N,10);
Third = ( mod(N,100) - (mod(N,10)))/10;
elseif (N<10) %1 digit
First = 0;
Second = 0;
Third = 0;
Fourth = mod(N,10);
end
NUMARR(1,1) = First;
NUMARR(1,2) = Second;
NUMARR(1,3) = Third;
NUMARR(1,4) = Fourth;
sort(NUMARR);
SmB = (NUMARR(1,1)*1000) + (NUMARR(1,2)*100) + (NUMARR(1,3)*10) + (NUMARR(1,4)) ;
end

Accepted Answer

Adam Danz
Adam Danz on 29 Apr 2019
Edited: Adam Danz on 29 Apr 2019
You're probably running the function without an input. You must include an input.
Big(77); %this doesn't produce an error
Big(); %This DOES produce an error
Big; %This DOES produce an error
Bin([]); %This DOES produce an error
  2 Comments
Adam Danz
Adam Danz on 29 Apr 2019
Nice job! If it breaks again, feel free to follow-up here with a comment.

Sign in to comment.

More Answers (0)

Products


Release

R2019a

Community Treasure Hunt

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

Start Hunting!