Shooting Method coding in MATLAB (ode45 | fzero): Lecture 7(a)

Поділитися
Вставка
  • Опубліковано 5 вер 2024
  • This video contains the construction of shooting method code for second order nonlinear differential equation with ode45 and fzero command in MATLAB.

КОМЕНТАРІ • 47

  • @8hng
    @8hng 2 роки тому

    excellent... job well done.

  • @Priya-hu7db
    @Priya-hu7db 3 роки тому +1

    In dy=zeros(2,1) what does it actually mean? I am not getting how (2, 1) are taken.Please tell.

  • @samuelanderson8112
    @samuelanderson8112 6 років тому +1

    Thank you for this great example!

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

    Professor how would I solve this system of first order edos numerically by plotting the graph for the different values ​​of (n). the derivatives are in relation to ha (r).
    a'/r = -e^2*v^2*(g^2 - 1)
    g' = - a*g/r
    given the boundary conditions
    a(0) = n a(inf)=0
    g(0) = 0 g(inf)=1
    where (e)=0.5 and (v)=1 are constant and n variavel. please give a helping hand there, I looked for and did not find any problems like this on the matlab website.

  • @sanjeevsharma-tn3gq
    @sanjeevsharma-tn3gq 7 років тому +1

    Thanks Dr. Rana.

  • @MechanicalCreativeContent
    @MechanicalCreativeContent 4 роки тому +2

    Working program for all your reference
    function shooting_method
    clc
    clear all
    x=0.5;
    x1=fzero(@solver,x);
    end
    function F=solver(x)
    options = odeset('RelTol',1e-8,'AbsTol',[1e-8 1e-8]);
    [t,y]=ode45(@equation,[0 1],[1 x],options);
    s=length(t);
    F=y(s,1)-exp(1);
    figure(1)
    plot(t,y(:,1))
    end
    function dy=equation(t,y)
    dy=zeros(2,1);
    dy(1)=y(2);
    dy(2)=t*exp(2*t)+y(1)-t*(y(2)^2);
    end

    • @Priya-hu7db
      @Priya-hu7db 3 роки тому

      when I tried this, error is coming.
      function shooting_method
      clc
      clear all
      x=0.5;
      x1=fzero(@solver,x);
      end
      error(function shooting_method
      Error: Function definitions are not permitted in this context.)

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

    Hello, For the plot part, I tried to insert the analytical solution on the same graph. However, the output is only giving me the analytical solution and a flat horizontal line at x=0. How can I solve that? Thank you

  • @26goldnugge
    @26goldnugge 4 роки тому

    you really help me out.

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

    Hello sir l have one problem with bvp4c function,i have written program for solving second order nolinear ode ,can you help me please

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

    Hlo Rana sir,
    I am trying to solve six dof coupled non linear differential equation which I am trying solve by using ode45 solver. But, the problem is that I need update the coordinates for Every time Interval. Can you help me out to solve it ?

  • @ashwin2112
    @ashwin2112 7 років тому +1

    Hello Dr. Rana,
    In line 9, you use odeset function. I don't understand the actual use of it. I tried reading about it. And also I took it out of the code and it still solves.
    BR

    • @scientificrana5650
      @scientificrana5650  7 років тому +2

      Odeset is necessary options only when you wish to change the tolerances. I mean you can loose the error thresholds using odeset to avoid default tolerances.
      If the tolerances are decreased, the accuracy of the result and the runtime is increased. This is more or less suitable depends on the complexity and requirement of problem equations. If you need rough results for millions of different initial conditions, larger tolerances are better. If you have enough time to wait and require accurate results, smaller tolerances should be preferred.
      Have a nice day!!

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

      Thank you very much for the explanation. On a different note, I'm currently working on my masters thesis. It involves modelling and simulation of semiconductors. I'm faced with solving the drift-diffusion equations, which are basically set of second order nonlinear PDEs. For now I'm working on 1-D ODE form. I'm very new to discrete numerical techniques. I plan to use Galerkin's FEM technique to solve it. Would you have any comments or suggestion at this point.

  • @9506595931
    @9506595931 7 років тому +1

    Hello Dr. Rana, I run your code and encountered with the following bunch of errors:
    ??? Input argument "x" is undefined.
    Error in ==> BVP>solver at 12
    [t,u]=ode45(@equation, [0, 1], [1, x], options);
    Error in ==> BVP at 5
    x1=fzero(solver,x);
    Please help me. My code is below for your kind consideration:
    function BVP
    clc
    clear all
    x = 0.5;
    x1=fzero(solver,x);
    end
    function F = solver(x)
    options= odeset('RelTol', 1e-8, 'AbsTol', [1e-8, 1e-8]);
    [t,u]=ode45(@equation, [0, 1], [1, x], options);
    s=length(t);
    F= u(s,1)-exp(1);
    figure(1)
    plot(t,u(:,1))
    end
    function dy = equation(t,y)
    dy = zeros(2,1);
    dy(1) = y(2);
    dy(2) = t*exp(2*t)+y(1)-t*y(2)^2;
    end
    I would appreciate if you could have a look at it.
    Thank you.

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

      Correct the syntax ""x1=fzero(@solver,x);". You forgot to use "@" .

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

      Thank you Dr. Rana, it worked now.

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

    hlo sir i run same code on my matlab R2013a it gives lots of warning in options line and one error in fzero solver line 5. how to handle this pls suggest me

  • @DrSohailAhmad-rr6he
    @DrSohailAhmad-rr6he Рік тому

    Hlo Rana sir,
    I am trying to solve 4 coupled non linear differential equation which I am trying solve by using ode45 solver. Do you have any related video please send me the link

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

    Dear Sir;
    What if I have a derivative BC in on the upper or lower limit of the domain?

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

      send me your problem on my email id scientificrana@gmail.com

  • @shahidrafiq962
    @shahidrafiq962 7 років тому +1

    Dear Dr.Rana
    i m reciving the following error when i run your code. Plz guide
    Error using fzero (line 289)
    FZERO cannot continue because user-supplied function_handle ==> solver failed with the error below.
    Not enough input arguments.
    Error in shooting_utube (line 5)
    x1=fzero(@solver,x);

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

      Are you working on more than one unknowns?. If not then send me your code for possible correction on my email id scientificrana@gmail.com or you can copy and paste the entire code here in the comment. I will reply accordingly.
      Thanks

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

      Thanks for ur reply.
      here is the code :
      function shooting_method
      clc
      clear all
      x=0.5;
      x1=fzero(@solver,x);
      end
      function F=solver(x)
      options=odeset('ReTol',le-8,'AbsTol',[le-8,le-8]);
      [t,u]=ode45(@equation,[0 1],[1 x],options);
      s=length(t);
      F=u(s,1)-exp(1);
      figure(1)
      plot(t,u(:,1))
      end
      function dy=equation(t,y)
      dy=zeros(2,1);
      dy(1)=y(2);
      dy(2)=t*exp(2*t)+y(1)-t*(y(2)^2);
      end

    • @scientificrana5650
      @scientificrana5650  7 років тому +1

      please correct this line.
      options = odeset('RelTol',1e-8,'AbsTol',[1e-8 1e-8]);

    • @shahidrafiq962
      @shahidrafiq962 7 років тому +1

      Thanks Dr. Rana
      code is running now.

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

      Most Welcome.

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

    Thanks Dr. Rana. I guess my problem is a small but funny one, probably because am still learning. I am supposed to use shooting method to solve a non-linear coupled ODE with boundary conditions. I have tried all possible ways but it seems not to be giving me expected results. Can i share you my code for corrections please?

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

      Have you gone through my another video on coupled nonlinear ODE solution
      ua-cam.com/video/KEyxX2dqjSg/v-deo.html
      If yes and didn't achieved success. You can send me your code for possible corrections to my email id scientificrana@gmail.com

    • @Priya-hu7db
      @Priya-hu7db 3 роки тому

      @@scientificrana5650 Sir,the video on coupled non linear ODE solution is not available to me. It is showing the video is private.Please tell the way by which I can watch the video..

  • @Levi-kq8ey
    @Levi-kq8ey 6 років тому

    Thank you

  • @m.faisalhanif6592
    @m.faisalhanif6592 3 роки тому

    Sir second video nh mile rhe ha is ki

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

    I have a doubt to solve more than two differential equations using shooting technique. i have sent the required file and matter to your email address.

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

      ua-cam.com/video/KEyxX2dqjSg/v-deo.html

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

      i have sent the question to your email. The question is bit different. The boundary condition is not given

  • @DavidTrejoG
    @DavidTrejoG 7 років тому +1

    LET'S GOOOOOOOOOOOOOOOO

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

    anyone can help me i want to need BVP4C coding

  • @m.faisalhanif6592
    @m.faisalhanif6592 3 роки тому

    Wo khn hn

  • @m.faisalhanif6592
    @m.faisalhanif6592 3 роки тому

    Is ka link shear kr do

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

    please help me sir

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

    any one from here to do matlab program for me

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

    Hello Dr. Rana!
    I sent you an email regarding this code. Please advise! Thank you very much!
    Best, Emily