How can I change the default function used by Matlab?

5 views (last 30 days)
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)

dpb
dpb on 20 Aug 2014
Edited: dpb on 20 Aug 2014
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
Matt J on 20 Aug 2014
I imagine he expects grayscale images as input.

Sign in to comment.


John D'Errico
John D'Errico on 20 Aug 2014
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.
  1 Comment
Liew
Liew on 20 Aug 2014
Oh, thanks for the info.
I did actually scan through the internet for the answer but did not found this piece of information about the default function.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!