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

Поділитися
Вставка
  • Опубліковано 14 жов 2024

КОМЕНТАРІ • 90

  • @brynmrsh
    @brynmrsh 6 років тому +26

    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 UA-cam.

  • @Handleoriginal12
    @Handleoriginal12 5 місяців тому +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 5 місяців тому +2

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

  • @imdavidsimon98
    @imdavidsimon98 Місяць тому

    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.

  • @ASIR070707
    @ASIR070707 4 місяці тому

    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?

  • @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

  • @furn6341
    @furn6341 Рік тому +1

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

  • @21seanlin
    @21seanlin 11 місяців тому

    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);

  • @salimamansoura7838
    @salimamansoura7838 3 роки тому +1

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

  • @stressedbyamountainofbooks
    @stressedbyamountainofbooks 6 місяців тому

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

  • @DhruvPatel-jf5gg
    @DhruvPatel-jf5gg Рік тому

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

  • @ghufransyed
    @ghufransyed 2 роки тому

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

  • @LL-kn1de
    @LL-kn1de 5 років тому +3

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

  • @anasene6678
    @anasene6678 6 років тому +4

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

  • @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?

  • @ashishhirani8617
    @ashishhirani8617 6 років тому +3

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

    • @cyber5787
      @cyber5787 6 років тому +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

  • @bhupenderkumarsom1975
    @bhupenderkumarsom1975 Рік тому

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

  • @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

  • @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.

  • @christopherstockman6917
    @christopherstockman6917 5 років тому

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

  • @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.

  • @shilpaagrawal2105
    @shilpaagrawal2105 2 місяці тому

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

  • @toastyh706
    @toastyh706 2 роки тому

    Thanks for the tutorial, it helped!

  • @EnDivine
    @EnDivine 7 років тому +5

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

  • @christostsombos8923
    @christostsombos8923 4 роки тому

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

  • @rah1092
    @rah1092 8 років тому

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

    • @CPPMechEngTutorials
      @CPPMechEngTutorials  8 років тому

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

  • @AntonHax
    @AntonHax 6 років тому +2

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

  • @aajamerepyar4586
    @aajamerepyar4586 4 місяці тому

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

  • @manarbuqai7231
    @manarbuqai7231 4 роки тому +1

    THANK YOUUUUU CPPMECHENG :):)

  • @nitinparate7857
    @nitinparate7857 3 роки тому

    How can we use ode45 inside a for loop

  • @ryan-oe6ft
    @ryan-oe6ft 6 років тому

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

  • @bienvenidoperez6630
    @bienvenidoperez6630 6 років тому

    Is also possible for an ODE no homogenous?

  • @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

  • @alyajazmina9215
    @alyajazmina9215 4 роки тому

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

  • @engi5843
    @engi5843 5 років тому +10

    ODE I wanna cry Industrial Engineering TT

  • @user-fo5jv3zu8jn2
    @user-fo5jv3zu8jn2 2 роки тому

    감사합니다.

  • @owen7185
    @owen7185 2 роки тому

    Awesome video 👍👍

  • @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

  • @Phamquest
    @Phamquest 7 років тому +4

    Very informative and clear, thanks!

  • @magnifiedmicrons
    @magnifiedmicrons 7 років тому

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

  • @James-sh7rr
    @James-sh7rr 6 років тому

    Very helpful. Thank you for sharing!

  • @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. ua-cam.com/video/hR9O7sVOArE/v-deo.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

  • @skeletonrowdie1768
    @skeletonrowdie1768 5 років тому

    wow! so nice and compact! thanks!

  • @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 !

  • @zhenisotarbay5159
    @zhenisotarbay5159 5 років тому

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

  • @atakangungor3438
    @atakangungor3438 6 років тому

    You are the Krall !!

  • @civelyze
    @civelyze 4 роки тому

    Thanks buddy 👍

  • @sunitadeb6076
    @sunitadeb6076 6 років тому

    thank you

  • @amnaalshamsi6400
    @amnaalshamsi6400 6 років тому

    thank yoooooooou from Oman

  • @austinwalker5176
    @austinwalker5176 10 місяців тому

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

  • @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?

  • @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

  • @saddamhussainsoomro2810
    @saddamhussainsoomro2810 6 років тому

    why x(: ?????

  • @Rockstar1376
    @Rockstar1376 8 років тому

    Thanks

  • @shivjikhanath3586
    @shivjikhanath3586 11 місяців тому

    Best

  • @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 6 років тому

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