How can I change the default function used by Matlab?
Show older comments
I am using the function of conv2 for filtering purpose and I get the error as below
Undefined function 'conv2' for input arguments of type 'double' and attributes 'full 3d real'.
I used which function and I noticed that the conv2 has 2 built-in function which is single and double and the default function used by Matlab is the single one
>> which conv2 -all
built-in (C:\Program Files\MATLAB\R2012b\toolbox\matlab\datafun\@single\conv2) % single method
built-in (C:\Program Files\MATLAB\R2012b\toolbox\matlab\datafun\@double\conv2) % double method
How can I redirect Matlab to use the function conv2 at double method?
Answers (2)
The problem is not that it's a double; the problem is that you passed a full 3D array to a 2D-limited function as the error says ...and attributes 'full 3d real'.
Pass a single plane or other 2D slice instead of the full array or use convn if actually doing 3D convolution.
ERRATUM -- inserted the missing not in front of the double...sorry, changes meaning significantly.
5 Comments
Matt J
on 20 Aug 2014
Liew commented
I wished that I could do the solution that you suggested but the function conv2 is written inside the function of filter2.m file which the cannot be written.
The 3D array actually comes from a tiff image file. Will it be different if I use another file format?
Liew
on 20 Aug 2014
Matt J
on 20 Aug 2014
I imagine he expects grayscale images as input.
Liew
on 20 Aug 2014
John D'Errico
on 20 Aug 2014
0 votes
Sorry, but you misunderstand what you have seen.
The default function is NOT a single precision one.
Functions in an @single directory will be called whenever single precision input is passed in. Likewiese, double precision input will cause the @double codes to be used.
The choice is made automatically, so you need not worry that the wrong one is being used.
Categories
Find more on Descriptive Statistics in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!