Yes, I have made sure to rename both the primary function and the actual m file to last_first_calcarea.m Error still shows up
EXACT same function, just different name. One has error "input arguments of type double", why?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello, I am new to Mathlab. I am taking a course that requires me to turn in my .m files (scripts and functions) with the file name lastname_first_function.m When I write a function, let's say this simple one calcarea.m
function [area] = calcarea(rad)
%calcarea calculates area of a circle
% Format of call: calcarea(radius)
area = 2*pi*rad;
end
compared to my turn in one last_first_calcarea.m
function [area] = last_first_calcarea(rad)
%calcarea calculates area of a circle
% Format of call: calcarea(radius)
area = 2*pi*rad;
end
The error I receive is "Undefined function 'last_first_calcarea' for input arguments of type 'double'."
Funny thing is that I sometimes do not get the error, but most of time, especially when I have longer functions/scripts, I get this error. The files are exactly the same, in the same directory, only thing is that their file names are different as well as their name in the m. file. What is causing the error, or is there any way to override it? Thanks
2 Kommentare
Jaime Muela Pérez
am 12 Mär. 2013
Hi,
Are you sure your .m file and the function are named the same way? It shouldn't fail if thats correct. I mean, if your function is
function [area] = my_function(rad) ...
your .m file must be named "my_function.m". Otherwise it won't find the function when you call it from the workspace.
Antworten (1)
Siehe auch
Kategorien
Mehr zu Workspace Variables and MAT Files finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!