1. Not finding help here? Sign up for a free 30min 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 errors

  1. Mar 14, 2009 #1
    1. The problem statement, all variables and given/known data
    plot using matlab:
    g = 3 cos (10pi t) convolved with 4 impulse (t +0.1)


    2. Relevant equations


    3. 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?
     
  2. jcsd
  3. Mar 14, 2009 #2

    D H

    User Avatar
    Staff Emeritus
    Science Advisor

    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.
     
  4. Mar 14, 2009 #3
    I dont quite really udnerstand what u mean :( And I dont get it is it a problem with the conv function or the plot function?
     
  5. Mar 14, 2009 #4

    D H

    User Avatar
    Staff Emeritus
    Science Advisor

    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?
     
  6. Mar 14, 2009 #5
    i am trying to solve the question given in the first post in matlab, its a hw
    :S
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook