matlab programming/error messages

Discussion in 'Homework Help' started by chrill3123, Sep 30, 2011.

  1. chrill3123

    Thread Starter New Member

    Apr 21, 2010
    9
    0
    My function in matlab is:

    t=0:0.01:8;
    w=1;
    y=1-((exp(-0.6*w*t))/(sqrt(1-0.6^2)))*sin(w.*sqrt(1-0.6^2)+acos(0.6));
    plot(t,y);
    hold on;
    w=5;
    y=1-((exp(-0.6*w*t))/(sqrt(1-0.6^2)))*sin(w.*sqrt(1-0.6^2)+acos(0.6));
    plot(t,y)

    but every time I´ll run it I get the following message:

    ??? Error using ==> mtimes
    Inner matrix dimensions must agree.
    Error in ==> Analytiskt_w0_w5 at 3
    y=1-((exp(-0.6*ω*t))/(sqrt(1-0.6^2)))*sin(ω.*t.*sqrt(1-0.6^2)+acos(0.6));

    I don´t see where I do wrong:mad:

    Any help is appreciated
     
  2. Georacer

    Moderator

    Nov 25, 2009
    5,142
    1,266
    Your code works to me in Matlab R2010b and its output graph is attached.
     
  3. Chrill3

    New Member

    Mar 8, 2010
    9
    0

    Iam sorry I gave you the wrong function the correct one is, and with this I get the error message from matlab:

    My function in matlab is:

    t=0:0.01:8;
    w=1;
    y=1-((exp(-0.6*w*t))/(sqrt(1-0.6^2)))*sin*t*(w.*sqrt(1-0.6^2)+acos(0.6));
    plot(t,y);
    hold on;
    w=5;
    y=1-((exp(-0.6*w*t))/(sqrt(1-0.6^2)))*sin*t*(w.*sqrt(1-0.6^2)+acos(0.6));
    plot(t,y)
     
  4. Georacer

    Moderator

    Nov 25, 2009
    5,142
    1,266
    That doesn't make much sense, now, does it? What is the meaning of the multiplication sin*t. Did you mean sin(t*...)?

    Please properly post your function.
     
  5. Chrill3

    New Member

    Mar 8, 2010
    9
    0
    I did find the solution to this problem it is:
    y=1-((exp(-0.6*w*t))/(sqrt(1-0.6^2))).*sin*t*(w.*sqrt(1-0.6^2)+acos(0.6));
    I needed an dot after (sqrt(1-0.6^2))).* for the matrix multiplication to work correctly
     
Loading...