1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

MATLAB question I dont think I got it right

  1. Apr 10, 2009 #1
    1. The problem statement, all variables and given/known data

    evaluate and plot this convolution:

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

    2. Relevant equations

    3. 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.
  2. jcsd
  3. Apr 10, 2009 #2
    Can some1 help please?
  4. Apr 11, 2009 #3
  5. Apr 12, 2009 #4
    can I know why no one is responding? is my question vague? am i doing something wrong/violating any rules?
  6. Apr 13, 2009 #5


    User Avatar
    Science Advisor

    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.
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Similar Discussions: MATLAB question I dont think I got it right