Error using conv2 First and second arguments must be single or double
8 views (last 30 days)
Show older comments
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]);
0 Comments
Accepted Answer
Matt J
on 11 Oct 2014
Edited: Matt J
on 11 Oct 2014
You can convert logicals to single or double using the commands single() or double().
2 Comments
Godwin Ikape
on 24 Mar 2022
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();
Godwin Ikape
on 24 Mar 2022
EDIT: Nevermind, I think I figured it out
a = single(r<p);
More Answers (0)
See Also
Categories
Find more on Multirate Signal Processing in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!