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

In summary, the conversation involves a student seeking help with plotting a function using Matlab. The function involves convolving two vectors, but the student is receiving an error about the vectors being different lengths. The expert advises checking the help facility for the conv function and reminds the student that convolving two vectors is equivalent to multiplying two polynomials. The expert also points out that the issue is not with the plot or conv functions, but with the student's approach to the problem.
  • #1
O.J.
199
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
  • #2
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
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?
 
  • #4
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
i am trying to solve the question given in the first post in matlab, its a hw
:S
 

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

1. What is the purpose of convolving two functions in Matlab?

The purpose of convolving two functions in Matlab is to combine or multiply the functions in such a way that the output represents the combined effects of the two functions. This can be useful in signal processing, image processing, and other types of data analysis.

2. How do I plot g = 3 cos (10pi t) convolved with 4 Impulse (t +0.1) in Matlab?

To plot this function in Matlab, you can use the "conv" function to convolve the two functions and then use the "plot" function to plot the resulting output. The code would look something like this:

t = linspace(0, 1, 100);
g = 3*cos(10*pi*t);
impulse = 4*impulse(t+0.1);
convolution = conv(g, impulse);
plot(t,convolution)

This will plot the convolution of the two functions over the range of t.

3. How does convolving two functions affect the resulting plot?

Convolving two functions can have various effects on the resulting plot depending on the properties of the functions. In general, it can smooth out or amplify certain features of the original functions, as well as introduce new features or distortions.

4. Can I change the parameters of the functions being convolved?

Yes, you can change the parameters of the functions being convolved. In the example given (g = 3 cos (10pi t) convolved with 4 Impulse (t +0.1)), you can change the amplitudes, frequencies, and time shifts of both functions to see how it affects the resulting plot.

5. Are there any limitations to convolving functions in Matlab?

There are a few limitations to convolving functions in Matlab. One limitation is that the functions being convolved must have the same number of data points. Another limitation is that the resulting plot may be affected by the resolution and range of the input data. Additionally, convolving large data sets can be computationally intensive and may require optimization techniques to improve performance.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
10
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
960
  • Engineering and Comp Sci Homework Help
Replies
2
Views
899
  • Engineering and Comp Sci Homework Help
Replies
6
Views
938
  • Engineering and Comp Sci Homework Help
Replies
3
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
137
  • Engineering and Comp Sci Homework Help
Replies
15
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
2K
Back
Top