# MATLAB errors

1. Mar 14, 2009

### O.J.

1. The problem statement, all variables and given/known data
plot using matlab:
g = 3 cos (10pi t) convolved with 4 impulse (t +0.1)

2. Relevant equations

3. 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?

2. Mar 14, 2009

### D H

Staff Emeritus
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.

3. Mar 14, 2009

### O.J.

I dont quite really udnerstand what u mean :( And I dont get it is it a problem with the conv function or the plot function?

4. Mar 14, 2009

### D H

Staff Emeritus
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?

5. Mar 14, 2009

### O.J.

i am trying to solve the question given in the first post in matlab, its a hw
:S