Convolving in Matlab

조회 수: 3 (최근 30일)
Cole
Cole 2011년 4월 7일
This is the code.
clear all;
i = 0;
j = 0;
folder = uigetdir;
Loaddata(folder)
for i=1:4833
%Reads in rows of numbers representing waveforms into a new vector
A(i,:) = Acquisitions(i,:)-32000;
end
t = -pi:0.01:pi;
B = tripuls(t);
for j=1:4833
W(j,:) = conv2(B,A(j,:));
end
And it keeps giving me this error: ??? Undefined function or method 'conv2' for input arguments of type 'int16'.
Error in ==> readinmaqscall at 18 W(j,:) = conv2(B,A(j,:));
So basically I am trying to convolve a triangular pulse with a bunch of different waveforms I have collected and this is the best way I know of going about it. It keeps giving me an error based on the type of data in the vectors. I am unsure what format it needs to be in for convolving.

채택된 답변

Andrew Newell
Andrew Newell 2011년 4월 7일
You should convert to double:
W(j,:) = conv(double(B),double(A(j,:)));
You can use conv2. As for the type, if I enter something like
conv(unit8(u),v)
for some vectors u and v, I get the message:
Warning: CONV2 on values of class UINT8 is obsolete.
Use CONV2(DOUBLE(A),DOUBLE(B)) or CONV2(SINGLE(A),SINGLE(B)) instead.
So that gives you some idea of the options.
EDIT: I don't know why conv2 doesn't accept integer types because it is a built-in function. However, if you input a double array with integer values, it will return a double array with integer values (see the article in Steve on Image Processing for an example).
  댓글 수: 1
Cole
Cole 2011년 4월 7일
Thanks, I just realized that it worked with doubles, is there a reason for this? is a double all you can use with conv?

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

Qiu
Qiu 2011년 12월 23일
I meet the same problem.
MATLAB keeps showing:
Undefined function or method 'conv2' for input arguments of type 'double' and attributes 'full 3d real'
  댓글 수: 1
Image Analyst
Image Analyst 2011년 12월 24일
You need to pass it a grayscale image, not a color (3D) image.

댓글을 달려면 로그인하십시오.


bym
bym 2011년 4월 7일
I think you want
conv()
instead of
conv2
  댓글 수: 1
Cole
Cole 2011년 4월 7일
I am sorry I forgot to mention it but I have tried conv() as well and it gives me the same error.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by