Error using conv2 First and second arguments must be single or double

I'm running the script below to prove the identity property of linear convolution ( x1(n)*d(n-n0)= x1(n-n0) )
However when I run the script I get the following errors
"Error using conv2 First and second arguments must be single or double.
Error in conv (line 38) c = conv2(a(:),b(:),shape);
Error in conv_m (line 10) ny = nyb:nye; y = conv(x,h);"
I think this has something to do with the matrix generated by the impseq function being "logical" instead of "double."
Any suggestions?
%Identity %x1(n)*d(n-n0)= x1(n-n0)
nx=[-50:50]; x1=cos(pi*nx/4).*(stepseq(-5,-50,50)- stepseq(20,-50,50));
%x1(n)*delta(n-n0)
[y4,m4]=impseq(5,-50,50);
[y5,m5]=conv_m(x1,nx,y4,m4);
subplot(2,2,3);stem(m5,y5,'k');title('x1*delta(nn0)'); xlabel('m');
[y1,m1]=sigshift(x1,nx,10);
subplot(2,2,4);stem(m4,y4,'k');title('x1(nn0)]');xlabel('m');
axis([-40 60 -10 20]);

 Akzeptierte Antwort

Matt J
Matt J am 11 Okt. 2014
Bearbeitet: Matt J am 11 Okt. 2014
You can convert logicals to single or double using the commands single() or double().

2 Kommentare

How do you convert a logical to single or double? Do I add the "single()" at the end of the operation or something?
Example:
a = r<p single();
EDIT: Nevermind, I think I figured it out
a = single(r<p);

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by