MATLAB: Write a convertCM() function that converts the given vector into the nearest whole number of feet and inches and returns it as two vectors named FEET and INCHES.

errorrun

function [inchs,feets] = convertCM(cm)
feets = cm.*0.032808;
integ = floor(feets);
fract=feets-integ;
inchs = fract*12;
feets = round(feets);
inchs = round(inchs);
end
Hey guys I tried to combine this code to answer the question, but each time i run it .. it keeps telling me:
>> convertCM
Not enough input arguments.
Error in convertCM (line 2)
feets = cm.*0.032808;

Best Answer

each time i run it .. it keeps telling me: Not enough input arguments.
I recommend you read the help on function basics, particularly Run functions in the editor. Your function needs an input therefore you cannot run it by simply clicking on the green run button which calls the function without any input. You'd have the same problem if you called sin without any input argument, matlab is not going to invent any input for you.
Try calling your function from the command line, with an input, e.g.:
>>[inch, feet] = convertCM(120)
or follow the instruction in the 2nd link above.
<Off-topic&gt feet is already the plural of foot. You don't put an s at the end of it. The plural of inch is inches. <\Off-topic&gt
Related Question