Why am I getting this error for Fspecial?

Hello, I'm just trying to run the fspecial function. This is the error I keep getting:
Undefined function 'checknargin' for input arguments of type 'double'.
Error in fspecial>ParseInputs (line 242) checknargin(1,3,nargin,mfilename);
Error in fspecial (line 97) [type, p2, p3] = ParseInputs(varargin{:});
I've looked at the function, and do not see a checknargin function defined.
I've uninstalled and reinstalled Matlab thinking that maybe the file was corrupted somehow. I still have this error. I've commented out this line, and it goes to the next check* function and says there is an error...
Can someone please tell me how to fix this?
Thank you!

 Accepted Answer

Are you sure that you are using MathWorks' version of fspecial()?
If you enter
>>which fspecial
Do you get something back like:
matlab\toolbox\images\images\fspecial.m
Then how are you attempting to call fspecial.m
Please show your call.

More Answers (1)

Amanda
Amanda on 4 Nov 2013
No. I was not getting that. It was accessing a version of the fspecial I'd saved in my Documents folder from my advisor. Thanks for recommending that! I've deleted my advisor's fspecial and now it is accessing the proper version. How could I do this without deleting the files? Is there a call I could use in the console? Or do I have to change my current folder every time so that Matlab is not confused?
Thank you!

4 Comments

I would recommend just renaming the file
fspecialAdvisor
Then there would be no naming conflict. Else, yes, you just have to manipulate the path or use packages to create individual namespaces (more complicated)
you can remove folders from the MATLAB path with rmpath() or by using pathtool. To launch pathtool, simply do
>>pathtool
I think you have to rename both the m-file name, and the function declaration line inside the m-file, right? Or maybe it's not required but it's recommended to avoid confusion.
Okay. Thanks so much for your help guys! I feel silly now.. in every other language you shouldn't name functions after built-in functions XD I don't know why I didn't think of that.

Sign in to comment.

Categories

Tags

Asked:

on 4 Nov 2013

Commented:

on 4 Nov 2013

Community Treasure Hunt

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

Start Hunting!