ME 340: Example, Solving ODEs using MATLAB's ode45 command

แชร์
ฝัง
  • เผยแพร่เมื่อ 11 ก.ย. 2024
  • Want to see more mechanical engineering instructional videos? Visit the Cal Poly Pomona Mechanical Engineering Department's video library, ME Online (www.cpp.edu/meo....

ความคิดเห็น • 90

  • @brynmrsh
    @brynmrsh 6 ปีที่แล้ว +25

    This is great. Now I can solve my homework problem. My school thinks that we become great engineers by being taught nothing, but being forced to use specific solution techniques, such as ode45, to solve problems that we have no idea how to even work out on paper. Thankfully, there are great schools which put examples on TH-cam.

  • @Handleoriginal12
    @Handleoriginal12 4 หลายเดือนก่อน +5

    I wish I stumbled on this video sooner. My professor expected us to know matlab without ever being taught it. I might just make it with this guide now

    • @Handleoriginal12
      @Handleoriginal12 4 หลายเดือนก่อน +2

      Update. I passed with a B. Thats a lot better than i expected. Thank you!

  • @imdavidsimon98
    @imdavidsimon98 23 วันที่ผ่านมา

    Thank you so much. I love you motto ' Learn by doing', with a simple example, you helped many of us understand what our teachers wasn't able (willing in my case) to explain.

  • @VDEngineering
    @VDEngineering 7 ปีที่แล้ว +20

    Could you please do a tutorial where the function has extra parameters which are time dependant?
    For example, the 6-DOF equations of motion have coefficients which change depending on the pitch angle and so on.

  • @Kay-dx8vm
    @Kay-dx8vm 3 ปีที่แล้ว +1

    Finally, Thank you so much for this video. Ive been sitting for hours following instruction from my textbook with a bunch of errors.

  • @anasene6678
    @anasene6678 6 ปีที่แล้ว +4

    You just saved my life.Thank you!!!!

  • @salimamansoura7838
    @salimamansoura7838 3 ปีที่แล้ว +1

    May God reward you for all your effort and all the valuable information you easily provide to us .

  • @ASIR070707
    @ASIR070707 3 หลายเดือนก่อน

    Great video, the first I watch learning about state-space presentation of ode. I followed the slides religiously and there is probably an error at 2:22. Last line: The first quantity (a_n-a/a_n) on the right-hand side of the equation should be multiplied by x_n and not x_n-1?

  • @furn6341
    @furn6341 11 หลายเดือนก่อน +1

    How can I plot y''-xy=0 with initial conditions y(0)=1, y'(0)=1 ?

  • @stressedbyamountainofbooks
    @stressedbyamountainofbooks 5 หลายเดือนก่อน

    How do you do this if the known value for xdot is when t=10, this is not initial value

  • @EnDivine
    @EnDivine 7 ปีที่แล้ว +5

    Very well explained sir! Thank you very much! :) :)

  • @manarbuqai7231
    @manarbuqai7231 4 ปีที่แล้ว +1

    THANK YOUUUUU CPPMECHENG :):)

  • @crosser7984
    @crosser7984 2 ปีที่แล้ว

    Thank You. You made my day. I've got errors that odearguments must return a column vector. Transposition at the end of function solved the problem. Thank you very much :D :D :D :D :D

  • @AntonHax
    @AntonHax 6 ปีที่แล้ว +2

    Thanks K-J! you helped us greatly, from sweden with kisses xxxo

  • @ghufransyed
    @ghufransyed 2 ปีที่แล้ว

    thank for this video, really helped me understand how to use the matlab ode function!

  • @bhupenderkumarsom1975
    @bhupenderkumarsom1975 ปีที่แล้ว

    struggling to solve a system of equations, could you please help me. It is a single server queuing model.

  • @DhruvPatel-jf5gg
    @DhruvPatel-jf5gg ปีที่แล้ว

    ultimately we are finding x right??...How Matlab going to find it from xdot=[xdot1,xdot2] values?...please guide me!!

  • @21seanlin
    @21seanlin 10 หลายเดือนก่อน

    excuse me, if I solve nonhomogeneous ODEs, Do I need to convert r(x1) into yp obtained by the modification rule? and if I use this method, how to define C,Kcos,Msin.
    Or should I just add r(x1) directly like this: dy1dx1(4)=y1(4)*Coefb/Coefa-y1(3)* Coefc/Coefa-y1(2)*Coefd/Coefa-y1(1)*Coefe/Coefa+r(x1);

  • @alemayehuwakjira7337
    @alemayehuwakjira7337 6 ปีที่แล้ว +1

    Dear sir thank you for your lecture on using ode45 for state variable solutions. my question is, is the name func a predefined name that can not be changed to other name? should I necessarily replace every time I save my file with same name func?

  • @LL-kn1de
    @LL-kn1de 5 ปีที่แล้ว +3

    Thank you! This really helps! Can you do a 2nd order d.e relate with RLC circuit problem?

  • @ashishhirani8617
    @ashishhirani8617 6 ปีที่แล้ว +3

    what is the meaning of (:,1) after the x in the plot function?

    • @cyber5787
      @cyber5787 5 ปีที่แล้ว +16

      It mean select every row from column 1
      for matrix
      1 6
      2 7
      3 8
      4 9
      5 10
      Example:
      (1:3 , 1) mean select row 1 to 3 from column 1 which gives
      1
      2
      3
      Example:
      (2:3 , 2) mean select row 2 to 3 from column 2, which gives
      7
      8
      if ( a:b, 1) and a, b are omitted, it mean select everything from column 1
      Hope that help :D

  • @engi5843
    @engi5843 5 ปีที่แล้ว +10

    ODE I wanna cry Industrial Engineering TT

  • @toastyh706
    @toastyh706 2 ปีที่แล้ว

    Thanks for the tutorial, it helped!

  • @vipulkumar5436
    @vipulkumar5436 7 ปีที่แล้ว +1

    at 2:22. shouldn't there be xn instead of xn-1 with (-an-1/an). talking about first expression on the RHS.

    • @leodaniel5245
      @leodaniel5245 5 ปีที่แล้ว

      You're right. Its a typo error.

  • @whitenancy4349
    @whitenancy4349 7 ปีที่แล้ว

    Thank you so much sir.
    I have a question that I would like to ask you
    If I have an equation: dy/dx = 8*y^k - 3*y The given numbers: k=[0.1:0.01:0.2] y0=0.6 x=[0 10] y1=2 How can I use ODE to solve the equation and use that solution to find x1 (x1 is at y1) for every value of k. CANNOT use arrayfun or find.

  • @virtually_passed
    @virtually_passed 5 ปีที่แล้ว +1

    This will also work:
    [t,x] = ode45(@(t,x) func(t,x),[1,5],[5 3]); %solves EoM and generates vector of time values from 1-5 with initial conditions x0=3 and v0=3
    figure
    plot(t,x(:,1))
    hold on
    plot(t,x(:,2))
    function xdot = func(t,x) %Outputs EoM in stae space form xdot = f(t,x)
    xdot(1)=x(2);
    xdot(2) = 20-7*x(2)-10*x(1);
    xdot=xdot';
    end

  • @aajamerepyar4586
    @aajamerepyar4586 3 หลายเดือนก่อน

    how can we plot x' vs t or x' vs x

  • @christopherstockman6917
    @christopherstockman6917 5 ปีที่แล้ว

    This helped... thanks! So this gives us the plot. But what can I do get the actual final equation of x?

  • @owen7185
    @owen7185 2 ปีที่แล้ว

    Awesome video 👍👍

  • @christostsombos8923
    @christostsombos8923 4 ปีที่แล้ว

    How can i use Ode45 if dx(2) is a piecewise function?

  • @Phamquest
    @Phamquest 6 ปีที่แล้ว +4

    Very informative and clear, thanks!

  • @shilpaagrawal2105
    @shilpaagrawal2105 29 วันที่ผ่านมา

    In this same way, kindly solve second order differential equation for van der pol system

  • @bienvenidoperez6630
    @bienvenidoperez6630 5 ปีที่แล้ว

    Is also possible for an ODE no homogenous?

  • @nitinparate7857
    @nitinparate7857 3 ปีที่แล้ว

    How can we use ode45 inside a for loop

  • @skeletonrowdie1768
    @skeletonrowdie1768 5 ปีที่แล้ว

    wow! so nice and compact! thanks!

  • @user-fo5jv3zu8jn2
    @user-fo5jv3zu8jn2 2 ปีที่แล้ว

    감사합니다.

  • @alyajazmina9215
    @alyajazmina9215 4 ปีที่แล้ว

    Shouldn't it be (:,2)) instead of 1?

  • @rah1092
    @rah1092 7 ปีที่แล้ว

    what is - xdot - for? am i able to use it for equations whose independent variable is not time? thanks

    • @CPPMechEngTutorials
      @CPPMechEngTutorials  7 ปีที่แล้ว

      "t" is any independent variable. In dynamic systems, time is usually the independent variable.

  • @manojdhanda2940
    @manojdhanda2940 5 ปีที่แล้ว

    great video cleared everything in 1 video thank you

  • @alarkthakkar1499
    @alarkthakkar1499 4 ปีที่แล้ว +1

    Thanks a ton! Was really helpful. :) Was looking for just this

  • @atakangungor3438
    @atakangungor3438 6 ปีที่แล้ว

    You are the Krall !!

  • @James-sh7rr
    @James-sh7rr 6 ปีที่แล้ว

    Very helpful. Thank you for sharing!

  • @magnifiedmicrons
    @magnifiedmicrons 7 ปีที่แล้ว

    very very good one
    thanks a lot-............
    it really helped me a lot

  • @Ziyad_A
    @Ziyad_A 5 ปีที่แล้ว

    Thanks Dr.

  • @Ankit-df8rw
    @Ankit-df8rw 5 ปีที่แล้ว

    thank u man!!! life saver

  • @christos1603
    @christos1603 5 ปีที่แล้ว

    thank you so much for this !

  • @debasis356
    @debasis356 7 ปีที่แล้ว

    What if the boundary condition x(0)=5; and x(10)=3. In my case, in boundary condition in place of xdot, x is given.

    • @TaterBot1000
      @TaterBot1000 7 ปีที่แล้ว

      Hey there. The ode isn't solvable unless all initial conditions at a particular given time is known. Thus having x(0) and x(10) doesn't help. Nor does having x(0) and xdot(10) or xdot(0) and xdot(10). None of those combinations make the problem solvable. In order to obtain a solution, you need x(0) and xdot(0) or x(10) and xdot(10), etc.

    • @debayan7
      @debayan7 3 ปีที่แล้ว

      you can use shooting method that will convert the boundary value problem to initial value problem. there are videos on this

  • @amnaalshamsi6400
    @amnaalshamsi6400 6 ปีที่แล้ว

    thank yoooooooou from Oman

  • @civelyze
    @civelyze 4 ปีที่แล้ว

    Thanks buddy 👍

  • @ryan-oe6ft
    @ryan-oe6ft 6 ปีที่แล้ว

    Thank you. The MatLab help files were very difficult to understand.

  • @zhenisotarbay5159
    @zhenisotarbay5159 5 ปีที่แล้ว

    [t,x]=ode45('func',[0 5],[5 3]);
    Error using ode45
    Too many input arguments.

  • @sunitadeb6076
    @sunitadeb6076 6 ปีที่แล้ว

    thank you

  • @saddamhussainsoomro2810
    @saddamhussainsoomro2810 5 ปีที่แล้ว

    why x(: ?????

  • @Hudmyq
    @Hudmyq 6 ปีที่แล้ว

    Hi, I dont know if you can read this. Thanks for your video. It is very clear. However, the problem what I'm trying to solve is two variables 2nd order differential equation set. For example, 32 * d^2x1/dt^2 + 48* d^2x2/dt^2 +3*dx1/dt +x1=0 ; 14*d^2x1/dt^2 +1.732*d^2x2/dt^2 +10* dx2/dt+ x2=0 . Can you please tell me how to do it in matlab ?

  • @haddedarbia4141
    @haddedarbia4141 7 ปีที่แล้ว

    hi plz can we use ode45 to solve a differential equation with non-constant coefficients !!

    • @TaterBot1000
      @TaterBot1000 7 ปีที่แล้ว +1

      If you're still searching for an example like that, you can find one in this video. th-cam.com/video/hR9O7sVOArE/w-d-xo.html The link already connects you to the example problem.
      There really isn't much difference with non-constant coefficients, so you've likely found out how by now.

    • @DrUARaja
      @DrUARaja 5 ปีที่แล้ว

      Yes we can

  • @BabyVedaChanel
    @BabyVedaChanel 7 ปีที่แล้ว

    z,t -C/ ρs V (x)kϕ(x)(1 + z2 ,x)-k/2 = 0 i want simulate this equation in mat lab please help me

  • @austinwalker5176
    @austinwalker5176 9 หลายเดือนก่อน

    MATLAB gives a "Not enough input arguments" error code, a "Unrecognized function or variable 'func'. Bad example.

  • @shivjikhanath3586
    @shivjikhanath3586 10 หลายเดือนก่อน

    Best

  • @Rockstar1376
    @Rockstar1376 8 ปีที่แล้ว

    Thanks

  • @cyrusIIIII
    @cyrusIIIII 7 ปีที่แล้ว

    what if you have system of equations of second order?

    • @CPPMechEngTutorials
      @CPPMechEngTutorials  7 ปีที่แล้ว

      If you have N second order ODEs, you need to convert them to 2*N first order ODEs.

    • @cyrusIIIII
      @cyrusIIIII 7 ปีที่แล้ว

      CPPMechEngTutorials Yes but what if they depend on each other for example I have xdoubledot in both of my equations?

  • @mjl7810
    @mjl7810 4 ปีที่แล้ว

    Knew you were a korean

  • @hernanes5533
    @hernanes5533 8 ปีที่แล้ว

    buenas vi tu codigo y me parece muy interesante... por favor me podrias ayudar a resolver esta practica soy muy novato en matlab.. solohernanes@gmail.com
    2 IDENTIFICACIÓN COMPETENCIAS CONTENIDO TEMÁTICO INDICADOR DE LOGRO
    Modelar matemáticamente sistemas analógicos SLTI.
    Sistemas lineales e invariantes en el tiempo - SLTI:
    Modelado de sistemas mediante ecuaciones diferenciales.
    Respuesta de entrada cero.
    Respuesta de estado cero.
    Estabilidad IIBO y BIBO.
    Representa matemáticamente un sistema en el dominio del tiempo mediante EDO.
    Representa matemáticamente un sistema en el dominio de la frecuencia mediante transformada de Laplace.
    Halla la respuesta de un sistema ante cualquier excitación.
    Determina la estabilidad IIBO y BIBO de un sistema a través de la ubicación de los polos.
    3 RECURSOS REQUERIDOS
    • Equipo de cómputo:
     Matlab, TheMathworks Inc.
    4 PROCEDIMIENTO
    Un sistema lineal invariante en el tiempo (SLTI - linear and time invariant) se puede modelar mediante la ecuación diferencial: Σ𝑎𝑖𝐷^(𝑖)𝑦(𝑡)𝑛𝑖=0=Σ𝑏𝑖𝐷^(𝑗)𝑥(𝑡)𝑚𝑗=0
    Donde la respuesta total 𝑦(𝑡) está dada por la respuesta de entrada cero (zero input) más la respuesta de estado cero (zero state): 𝑦(𝑡)=𝑦𝑧𝑖(𝑡)+𝑦𝑧𝑠(𝑡)=Σ𝑐𝑘𝑒^(𝜆𝑘𝑡)+𝑥(𝑡)∗ℎ(𝑡)
    Donde ℎ(𝑡) es la respuesta al impulso, 𝜆𝑘 es la 𝑘-ésima raíz de la ecuación característica y 𝑐𝑘 son constantes a determinar con las condiciones iniciales.
    La función de transferencia del sistema se define como:
    ℒ{ℎ(𝑡)}=𝐻(𝑠)=𝑌(𝑠)𝑋(𝑠)=Σ𝑏𝑖𝑠^𝑗=0Σ𝑎𝑖𝑠^𝑖=0=Σ𝑏𝑖𝑠^𝑗=0Π(𝑠−𝜆𝑘)
    4.1 PROCEDIMIENTO DE LA PRÁCTICA
    Dado el sistema:
    𝑎𝑛*(𝑑^𝑛*𝑦(𝑡))/(𝑑𝑡^𝑛)+𝑎𝑛−1*𝑑^𝑛−1𝑦(𝑡)/𝑑𝑡^𝑛−1+⋯+𝑎1𝑑𝑦(𝑡)𝑑𝑡+𝑎0𝑦(𝑡)=𝑏𝑚𝑑𝑚𝑥(𝑡)𝑑𝑡𝑚+𝑏𝑚−1𝑑𝑚−1𝑥(𝑡)𝑑𝑡𝑚−1+⋯+𝑏1𝑑𝑥(𝑡)𝑑𝑡+𝑏0𝑥(𝑡)
    Diseñe una rutina en Matlab que tenga como parámetros de entrada única y exclusivamente 𝑏, 𝑎, las condiciones iniciales del sistema y la ecuación de la señal de entrada. Tanto 𝑏 como 𝑎 se deben ingresar como vectores y no se le debe exigir al usuario que ingrese estos elementos número por número. Las condiciones iniciales sí se pueden pedir de forma individual, es decir, una por una.
    Con esta información que se le pide al usuario, el programa debe hacer lo siguiente:
    a. Grafique los polos del sistema en el plano de Argand.
    b. Indique en una ventana emergente si el sistema es IIBO estable, inestable o marginalmente estable.
    c. Indique en otra ventana emergente si el sistema es BIBO estable, inestable o marginalmente estable.
    d. Muestre en la ventana de comando la función de transferencia del sistema.
    e. Muestre en la ventana de comando la respuesta de entrada cero.
    f. Muestre en la ventana de comando la respuesta de estado cero.
    g. Muestre una gráfica con cuatro subplots que muestren 𝑥(𝑡),𝑦(𝑡),𝑦𝑧𝑖(𝑡) e 𝑦𝑧𝑠(𝑡) en el intervalo 0≤𝑡≤10.
    5 PARÁMETROS PARA ELABORACIÓN DEL INFORME
    a. Funciones y comandos útiles: eval, roots, dsolve, int, laplace, syms, entre otros.
    b. Debe ser cuidadoso al etiquetar los ejes y las gráficas. Gráfica sin etiquetas no se tendrán en cuenta.
    c. Envíe los scripts en un solo archivo .m

  • @cuongho7007
    @cuongho7007 6 ปีที่แล้ว

    if coeficient is matrix so how i can do it..

    • @bienvenidoperez6630
      @bienvenidoperez6630 5 ปีที่แล้ว

      I'm doing a problem with matrix and no homogenous. Have the answer?