• Support PF! Buy your school textbooks, materials and every day products Here!

MATLAB question I dont think I got it right

  • Thread starter O.J.
  • Start date
  • #1
199
0

Homework Statement



evaluate and plot this convolution:

y[n] = 2^n u[n+4] * u[n-3]



Homework Equations





The Attempt at a Solution



This is my code:

n0 = 20;
n = -n0:n0;
u1 = (n+4)>=0;
f1 = 2.^n;

x = f1 .*u1;
h = (n-3)>0;
y = conv (x,h);
l = length(x)+length(h)-1;
k2 = linspace(-n0,n0, l);
stem (k2, y);
xlabel ('n');
ylabel ('impulse response');
title ('System unit impulse resopnse Q1');


I get a plot, but I get suspicious about it because it doesnt seem to converge, so i change n0 (just to see) and make it 100, it still looks the same. I make it 1000, 0,-10, it still looks the same which tells me there is something wrong in my code. Awaiting your help.
 

Answers and Replies

  • #2
199
0
Can some1 help please?
 
  • #3
199
0
bump!
 
  • #4
199
0
can I know why no one is responding? is my question vague? am i doing something wrong/violating any rules?
 
  • #5
MATLABdude
Science Advisor
1,655
4
Well, you think that it's incorrect, so what do you think the plot *should* look like? Have you, on paper, taken the Laplace transform of the two functions, multiplied them, and then applied an inverse transform?

FWIW, I plot what you have, and it does converge (or at least come down from its peak value to the right of the maxima). As for why it looks similar when you try n0=1000 (and explodes to pretty large values) realize that neither function is finite in length, and thus, neither is the convolution of the two (at least, when you consider the convolution from -inf to inf). By selecting a terminating value of n0, you arbitrarily truncate those functions at those values.

When you ask very specific questions, its often hit or miss as to whether or not someone remembers it right off the bat. I (barely) remember convolutions as I haven't used this in a while. Also, people are usually more inclined to respond to posts that have no responses. By the process of bumping (and bumping several times), people are less likely to respond to, or even read, your post because they see that there are replies.
 

Related Threads for: MATLAB question I dont think I got it right

  • Last Post
Replies
8
Views
571
Replies
3
Views
4K
Replies
7
Views
3K
Replies
8
Views
949
Replies
1
Views
885
Replies
3
Views
854
  • Last Post
Replies
9
Views
2K
Top