Plotting g = 3 cos (10pi t) Convolved with 4 Impulse (t +0.1) in Matlab

Join the discussion
Registration is free. Start your own thread to ask a follow-up.
4 replies · 5K views
O.J.
Messages
198
Reaction score
0

Homework Statement


plot using matlab:
g = 3 cos (10pi t) convolved with 4 impulse (t +0.1)


Homework Equations




The Attempt at a Solution



x = -10:0.1:10;
u = 3*cos (10*pi*x);
v = 4*dirac(x + 1./10);
y = conv (u,v);
plot (x,y);
but i keep getting this error:
Error using ==> plot
Vectors must be the same lengths

any ideas?
 
Physics news on Phys.org
The error means that your vectors x and y are not the same length. How would *you* (not Matlab) go about plotting a vector of length 100 versus a vector of length 199? You are asking Matlab to do something that doesn't make sense.

Matlab has a great help facility.

>> help conv

CONV Convolution and polynomial multiplication.
C = CONV(A, B) convolves vectors A and B. The resulting
vector is length LENGTH(A)+LENGTH(B)-1.
If A and B are vectors of polynomial coefficients, convolving
them is equivalent to multiplying the two polynomials.
 
I don't quite really udnerstand what u mean :( And I don't get it is it a problem with the conv function or the plot function?
 
The problem is neither with the plot function nor the conv function. It is with you. You are asking Matlab to do something that doesn't make any sense.

What are you trying to accomplish?
 
i am trying to solve the question given in the first post in matlab, its a hw
:S