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

Click For Summary

Discussion Overview

The discussion revolves around a homework problem involving the convolution of a cosine function with an impulse function in Matlab. Participants are attempting to plot the result and troubleshoot an error related to vector lengths.

Discussion Character

  • Homework-related, Technical explanation

Main Points Raised

  • One participant presents a Matlab code snippet for convolving a cosine function with an impulse function and encounters a vector length error during plotting.
  • Another participant explains that the error arises because the vectors being plotted must be of the same length and references the behavior of the conv function in Matlab.
  • A third participant expresses confusion about whether the issue lies with the conv function or the plot function.
  • A subsequent reply asserts that the problem is with the user's understanding rather than the functions themselves, questioning the user's objectives.
  • The original poster reiterates their intent to solve the homework question using Matlab.

Areas of Agreement / Disagreement

Participants do not reach a consensus on the nature of the problem, with some focusing on the technical aspects of the code and others on the user's understanding of the functions involved.

Contextual Notes

The discussion highlights potential misunderstandings regarding the output length of the conv function and its implications for plotting, but does not resolve these issues.

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
 

Similar threads

  • · Replies 10 ·
Replies
10
Views
2K
Replies
2
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
Replies
2
Views
2K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
Replies
15
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 4 ·
Replies
4
Views
3K