EXACT same function, just different name. One has error "input arguments of type double", why?
Mostrar comentarios más antiguos
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 comentarios
Joe
el 12 de Mzo. de 2013
Jaime Muela Pérez
el 12 de Mzo. de 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.
Respuestas (1)
Image Analyst
el 12 de Mzo. de 2013
What does this show:
>> which -all last_first_calcarea
Categorías
Más información sobre Workspace Variables and MAT Files en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!