MATLAB question I dont think I got it right

  • Thread starter O.J.
  • Start date
  • Tags
    Matlab
  • #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 doesn't 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
Can some1 help please?
 
  • #3
bump!
 
  • #4
can I know why no one is responding? is my question vague? am i doing something wrong/violating any rules?
 
  • #5
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.
 

Suggested for: MATLAB question I dont think I got it right

Replies
5
Views
724
Replies
1
Views
619
Replies
3
Views
448
Replies
10
Views
763
Replies
1
Views
476
Replies
11
Views
542
Replies
3
Views
610
Replies
1
Views
605
Back
Top