Matlab

Discussion in 'Math' started by jagjit Sehra, Mar 5, 2008.

  1. jagjit Sehra

    Thread Starter Member

    Feb 29, 2008
    25
    0
    Hi Folks, Got another quick question for you. I am trying to enter the folowing function into MATLAB to get a plot graph. However I am getting the following error. I know its something to do with the size of the arrays, however I dont understand how to get around the problem. Thank you in advance for your pearls of wisdom.

    >> t=linspace(0,6);
    >> vC= 2*exp(-2*t)+ 4*t*exp(-2*t);
    ??? Error using ==> mtimes
    Inner matrix dimensions must agree.

    jag.
     
  2. jagjit Sehra

    Thread Starter Member

    Feb 29, 2008
    25
    0
    Hi Folks,
    I have got it to work by replacing each '*' by '.*' apparantly without using the dot MATLAB multiplies the whole matrix by another matrix. But using the dot only multiples elements. Is what I have done correct or have I misunderstood the solution.

    Jag.
     
  3. Dave

    Retired Moderator

    Nov 17, 2003
    6,960
    144
    Yes this is right.

    The ".*" operator does element-wise multiplication of matrices.

    i.e. [2 3 4] .* [3 4 5] = [6 12 20]

    Dave
     
Loading...