Ode45 Definition and 56 Threads

  1. V

    Using ODE45 on Matlab to Integrate A Problem

    I got the answer for this question but I was wondering about stepsize when it comes to a problem like this? Is there a way to change the step size? Would my step size change in line 20, or would it change in line 3? I tried changing line 3 to be t=0:100:17.1 but then I get a error message, so...
  2. patric44

    MATLAB Change the value of a variable at each time step in matlab?

    hi guys I am trying to implement the a second order differential equation tat contains a time dependent term, the equation looks something like r'' = -\mu/r^3+(g/g^3-m/m^3) the idea is that i want to calculate 'r' the position vector of a point, that is dependent on vectors g and m, I tired to...
  3. patric44

    MATLAB Transforming long symbolic expressions to use in matlab ode45?

    hi guys i build a little function that outputs a symbolic expression like that below, this is only a part of it: (105*(x(5)^2/r^2 - 1)^2)/8 + (210*x(5)^2*(x(5)^2/r^2 - 1))/r^2))/(r^2)^(9/2) + (8*R^7*u*x(5) the problem is the only way to integrate this output is to expand the function externally...
  4. I

    ODE solver for second Order ODE with Stiffness and Mass Matrices

    i am new to MATLAB and and as shown below I have a second order differential equation M*u''+K*u=F(t) where M is the mass matrix and K is the stifness matrix and u is the displacement. and i have to write a code for MATLAB using ODE45 to get a solution for u. there was not so much information on...
  5. S

    MATLAB How can I plot a Hohmann Transfer Orbit in MATLAB using ode45?

    function Asteroid_Mining clc %Initial conditions g0 = 9.81; %gravity (m/s^2) p = 1.225; %atmospheric density at sea level (kg/m3) Re = 6378; %radius of Earth (km) Ra = 7.431e7; %distance of Bennu from Earth in (km) [August 2023] G = 6.674e-11/1e9; % Gravitational constant (km3/kg.s2) mu =...
  6. S

    MATLAB Question about how solve 2 body problem in orbit using MATLAB ode45

    hi guys, I'm trying to write a program in MATLAB to solve and plot equation of motion of 2 body problem but it errors as i don't know what it says! do you know how to help me? please! The main equation is r(double dot)=-(mu)*r(hat)/r^3 The code that i wrote is: clear all close all clc...
  7. patric44

    Using Matlab ode45 to solve a simple 2 body problem

    hi guys i am having some truble solving a simple 2body problem in MATLAB , basicaly i have a table of data that came from a simulation of a satellite orbiting the Earth with 1 min interval between them , i will only take the first inital position and velocity from that table and i sould...
  8. patric44

    Question about the nonlinear Hooke's law

    hi guys i saw this problem online about using the MATLAB ode45 to solve the nonlinear Hoock's law and its specifically stated that the nonlinear hoock's law is given by $$F = k\;u + \epsilon\;u^{3}$$ , but when expanding the potential function in a Taylor series where you obtain the force...
  9. M

    MATLAB Solving the Duffing Equation with ODE45

    Hi PF I am trying to replicate the phase portrait at the bottom right of this page: https://en.wikipedia.org/wiki/Duffing_equation What I have is this: global delta alpha beta gamma OMEG delta = 0.3; % DAMPING alpha = -1; % STIFFNESS beta = 1; % RESTORATION NONLINEARITY OMEG...
  10. D

    MATLAB Coupled systems of ODE's solved by matlabs ODE45 (Runge Kutta Alg.)

    Use the code as needed, its free to all! Please note this code is only for one mfile, you will need to add them all to the same file path for it to work. Others will be in the next post. They have to run simultaneously to work and give output. function dydt =...
  11. JayFlynn

    MATLAB Plotting the tragectory of an asteroid in MATLAB

    I am trying to plot the trajectory of an asteroid in MATLAB using ode23. The only bodies in the system are The Sun, Earth, Mars and Jupiter and their orbital data has been loaded from data files. I have picked arbitrary initial conditions for the asteroid and believe my forces are correct. My...
  12. Sirsh

    MATLAB How to Output k_mb for Plotting in ODE45?

    Hi all, I have the following ode code, and I want to know how I could output the variable "k_mb" within my main script so that I can plot it to see if it's actually active when the solver is integrating. odescript function zdot = odenesttest(t,z) global r_p r_g I_p I_g m_p m_g V k_mb A_or_B =...
  13. F

    MATLAB Finite difference numerical integration or ode45?

    I'm trying to numerically solve the time dependent Schrödinger equation and I've been told that the best approach is to numerically integrate using a finite difference method, however I don't understand why I couldn't just use ode45 to solve it?! Is the finite difference (interpolation) method...
  14. P

    Modeling Motion of Earth with Matlab using ODE45

    Homework Statement So I am trying to model the motion of the Earth around the Sun using ode45. I modeled this using an euler-cromer scheme, but I would like to get familiar with using a solver. I wrote the code for an Euler-cromer and it worked just fine. However, when I try to use the same...
  15. B

    MATLAB How to give a step input in Matlab?

    Hello, I have a state space equation at hand.. This attached with this... Now the term (theta double dot) is a positive step for 0,136 milli seconds and negative step for next 0,136 millisecond and 0 at all other times. So that when I simulate I will get a graph as below: This is the nature...
  16. Adrian Soo

    MATLAB Piecewise MATLAB ode45 problem for Lennard-Jones

    I could run the MATLAB codes but the main issue is that data for T1 and U1 could not be produced. I am currently trying to calculate the displacement of two particles after the collision with walls with length of 10 units. Here are the codes. If you don't understand its context, you can refer...
  17. B

    Ode45 for solution of 4 d.o.f. problem

    Hi Folks, I have made up this code in an attempt to find the response time a 4 dof problem. However, I do not get an oscillatory response as I expect, instead I get a straight line which drops off towards the end. Not sure what is happening..any ideas..? function f = Simple_Planetary(t,y) f =...
  18. V

    Laser Rate Equation Using ODE45 in MATLAB?

    Hi, I've attached the problem that I'm trying to solve. I've also done the manual calculations to calculate Ithreshold. I'm not very good with MATLAB and I need MATLAB code for laser rate equations and I also need to plot LI characteristic of the laser. I_th=qV/(η_i τ) N_th=qV/(η_i τ)...
  19. C

    MATLAB Projectile motion with friction in MATLAB (ODE45)

    I'm working on a little project where I want to plot the motion of a projectile with air resistance. The air resistance can be assumed to be proportional to the velocity squared. F_{f}=-Bv^{2} F_{f,x}=F_{f}\frac{v_{x}}{v}, \ \ F_{f,y}=F_{f}\frac{v_{y}}{v} where B depends on the height...
  20. E

    Solving ODE w/ Matlab ode45: Error Message Explained

    I'm trying to solve an ODE using matlab's ode45, but I'm receiving the following error: Warning: Failure at t=4.509803e+01. Unable to meet integration tolerances without reducing the step size below the smallest value allowed (1.136868e-13) at time t. Can anybody explain what this means?
  21. S

    MATLAB How Do You Solve Coupled ODEs Using MATLAB's ode45?

    Help me with coupled ode45 equations in MATLAB please I have no idea to turn these into MATLAB code, and here is the porblem: y(1)' = y(2) y(2)' = - (r+re)/(L+le)*y(2) - y(1)/c*(l+le) y(3)' = y(4) y(4)' = -c*y(4).^2 /m+L*y(2).^2/(2*m) where re = ro+Rpr*z+Lpr*z' le = Lo+Lpr*z the rest...
  22. N

    MATLAB Is it Possible to Solve a Coupled System of ODEs with ODE45 in MatLAB?

    Hi I am trying to solve a simple set of coupled ODE's by ODE45. The coupled system is given by: function xprime = eoms(t, x) xprime = [ 1e9 + 5.0e4*x(3) - 50*x(1); 4.0e1*x(1) - 3.3e3*x(2); 2.0e3*x(2) - 5e4*x(3) + 3.5e7*heaviside(t-1)*x(4); 1.0e3*x(2) -...
  23. Y

    MATLAB Matlab ode45 referencing past value

    I am using ode45, but have a value that is based upon its own past values. I want to be able to include a parameter that equals (y(3) at time t) - (y(3) at time (t- 30days)). Is there a way to include this using ode45? Thank you in advance!
  24. H

    "? Input argument "x2" is undefined. MATLAB

    Homework Statement Hello! I have been given a problem of ordinary differential equations to be solved in MATLAB by ode45. The equations are on a sheet but you can see what equations i put in. I did as the teacher instructed but MATLAB gives me a error message. Can you see what I misunderstood...
  25. H

    Simulating velocity behavior w/ IF conditionals and ODE45

    Hello, I've made a script to solve a non-linear ordinary differential equation for the temperature (lumped-mass) of a brake rotor due to some constant deceleration of a race car (Qbrake in script). The problem I'm having is properly simulating the velocity of the car. What I'd like for it to...
  26. K

    MATLAB Solving Diff. Eq. with MATLAB ode45

    Hello, I am trying to write a program on MATLAB using ode45 to solve the following equations: S'=-bSZ-sS Z'=bSZ+gR-aSZ R'=sS+aSZ-gR These are all derivatives with respect to t, differential equations. a, b, a and g are all constants. I realize I need to have two m files, one...
  27. J

    Solving nonlinear ODE with ODE45 fails at bifurcation point?

    Hello everybody, Background and problem description I have derived an analytical expression for an implicit frequency response function. To verify it, I would like to check with a numerical solution. For very weak nonlinearities, congruence is obtained. For weak nonlinearities, the...
  28. Z

    Matlab code using ode45 difficulty

    Homework Statement I've been trying to get this code to work: ode45(@(t,y) fallode(t,y,B), [0, tmax], [31330, 0]) Homework Equations function dy = fallode(t, y, B) % ODE function to model a fall over a large range of % altitudes, reaching up to high subsonic Mach numbers. % y(1) is...
  29. H

    MATLAB Matlab ODE45: solving with coefficients that are functions of time

    Hello all, I am new to the ODE solvers in Matlab and am trying to learn: First, I am solving a 2nd order ODE to determine x(t), x'(t), and x''(t). No problem. Then, I am using these solutions to calculate two coefficients (that are functions of time) that are used in a second, second order...
  30. A

    MATLAB Get the derivative with MATLAB ode45

    Hello every one! I'm trying to solve a differential equation y' = f(t,y) with MATLAB ode45. Besides the original y, y' is also very useful to me. But I simply don't know how to get it. Is there any convenient method to do this? Or what I can do is just to compute y in many point and use diff...
  31. O

    How to Stop Integration in ode45 When y<=0 is Reached?

    Hii, I am using 'OutputFcn' to check integration values after each step. Druing my solution I want to stop integration after I reach y<=0. Problem I am acing is that, after each iteration solver returns me array of y which is correspond to a array of t rather than at each point of t. Thats...
  32. F

    MATLAB Help with ODE45 and Plotting in MATLAB Loop

    Hey i need help in ODE45...i'm new to PF...pls help me i have the following code >>for i=1:5 >>tspan=[0 30] >>h0=Hv(i) >>[t,h]=ode45['a ODEfunction',tspan,h0] >>plot(t,h) >>end in this loop how can i save 5 values of [t,h], as t, h produces each loop run like follows t= 1 2 3...
  33. S

    Confusion, matlab, ode45 variables.

    Homework Statement I am very confused over how MATLAB knows which variables are changeable variables in ode45. Homework Equations // The Attempt at a Solution My input is p Earlier have defined; a = 1; k = 1; w = 1/3; Then I want to figure out adot and adoubledot from...
  34. S

    Ode45 to solve nonlinear second order ode

    Homework Statement I'm given two equations first (d^2)*r/dt^2 - r((d*theta/dt)^2)= (-A)/r^2 --- this is a non linear second order differential equation second (r^2)*((d*theta)/dt)=B B and A are...
  35. H

    Matlab ode45 Help: Solving Orbital Propagation Issues

    Homework Statement I need to create an orbit propagator for the orbit of a specified body and graph it. I've written a code that works and correctly gives me a circular orbit for a satellite in geosynchronous orbit and it appears to correctly display the orbit of the Earth for one year. I'm...
  36. J

    MATLAB Solving Nonlinear Equations of Motion with ODE45 MATLAB

    Hi! I have to solve the nonlinear equations of motion in the article (16) (17) (18). I Trasform the system in a system of first order differential equations but i don't have the initial conditions. Is it possible to solve it with the ode45 MATLAB function?
  37. M

    MATLAB ODE45 Help for Matlab: Fix Your Code Now

    Matlab ODE45 Help?? function dy = prob_52 (t,y) dy = cos(y) - (sin (t)*y); [t,y] = ode45 (@prob_52,[0,1],0) plot (t,y) xlabel ('Time') ylabel ('Function Value') I was told my code is incorrect. Does anyone have suggestions on where I'm going wrong? Thanks
  38. M

    Using ODE45 to Solve Matrix Differential Equations in MATLAB

    Homework Statement If we have differential variable of matrix kind ( with dimention 3*3 ) and non matrix ( with dimention 1) simaltanously and as a couple ,how can we use ode45 ? If we have only matrix kind , we can use m file of ode at first with the command of reshape (3,3) and then change...
  39. M

    MATLAB Solving Matrix Differential Equations with ODE45

    If we have differential variable of matrix kind ( with dimention 3*3 ) and non matrix ( with dimention 1) simaltanously and as a couple ,how can we use ode45 ? If we have only matrix kind , we can use m file of ode at first with the command of reshape (3,3) and then change it to column one.What...
  40. D

    Matlab- expressing derivatives in an equation with ode45?

    Homework Statement (-1)^4*xdx + (8y-y^2-13)dy=0; y(0)=4; 1. Use dsolve to obtain a solution. 2. As dsolve was not much help fi nd an implicit solution of the form f(x, y) = 4 Homework Equations --- The Attempt at a Solution the dsolve part was easy, i just did: syms x y t...
  41. A

    How to access function's (and variable's) value in ODE45 right after each step?

    first I was thinking it was very easy to obtain a variable's or function's value after each step within ode45 subfunction. But just yesterday I found out all I had done before might be incorrect! just see the MATLAB code below: I believed the two plots should be exactly the same but they are...
  42. B

    MATLAB Using ode45 in a for Cycle: Adding Parameters to odefun

    Hi guys, I want to run a for cycle with ode45 inside. However, some parameters that I define in odefun (the differential equation in order to dy/dt, for instance) assume different values in each iteration of that cycle. I find help examples showing odefun only receiving t and y... Is...
  43. K

    MATLAB Help, solving simple PDE with ODE45 or ODE23 solver in matlab

    guys please help me, I'm trying to solve a simple moving PDE equation in matlab. The equation I'm trying to solve is dq(x,t)/dt=-c*dq(x,t)/dx with initial condition for example q(x,0)=exp(-(x-5)^2) c is a constant. What i want to do is to first discritize the initial condition with...
  44. T

    (ODE45) problem of solving laser rate equation

    I want to simulate the reference’s passive Q switch process. The reference is Shengzhi Zhao, Lei Chen, Hongming Zhao, Guiqiu Li, Lu Zhang, Kejian Yang. Laser–diode-pumped passively Q-switched Nd3+:NaY(WO4)2 laser with GaAs saturable absorber. Optics & Laser Technology 37 (2005) 187–191. I...
  45. K

    MATLAB Solve 7 DOF Error in MATLAB with Ode45 - Help from Experts

    I am writing a program to find 7 degrees of freedom, but I keep getting an error message that "the argument 'x' is undefined". Could somebody please tell me what I am doing wrong? function dx = IMatrix(t,x,lamda,E) I1 = 4250; I2 = 5175; I3 = 8397; lamda(1) = 2/(38^.5); lamda(2) =...
  46. S

    MATLAB Matlab Help:Stop ode45 with OutpuFcn

    Hi everybody, I'm trying to solve this first-order ODEs system:and I'd like to stop the solution when y, i.e u(3), becomes negative: %system function rhs=particle(t,u) global k rhs=[u(2); -k*u(1)*sqrt(u(2)*u(2)+u(4)*u(4)); u(4); -9.81-k*abs(u(4))*sqrt(u(2)*u(2)+u(4)*u(4))]; where...
  47. N

    How to solve an ode using MatLabs ode23 or ode45

    Homework Statement Use one of MatLabs built in functions ode23 or ode45 to draw a curve of the current i(t) when 0.001i''(t) + 200i'(t) + 1/(20*10^-9)i(t)=0 and i(0)=0 i'(0)=10000 Homework Equations That would be the one above. The Attempt at a Solution I know from my work doing this by...
  48. T

    MATLAB Setting Initial Conditions for ode45() with f(1.5) Known

    Hey guys, I was just wondering if anyone knows how to set the initial conditions for ode45() if you know f(1.5) but NOT f(0) Currently I have >> ode45(f, [0 1 1.8 2.1], [1.5 .5]) But this creates the following error: ? Error using ==> funfun/private/odearguments @(T,Y)...
  49. M

    MATLAB .Solving ODE Error in MATLAB Using ODE45 Solver

    Dear all. I am trying to solve an ODE in MATLAB using ODE45 solver. But the programe keep saying ? Input argument "y" is undefined. Error in ==> lvv at 4 yprime=[a*y(1)-b*y(1)*y(2);-r*y(2)+c*y(1)*y(2)]; Can anybody be of help? Please. The complete code is this: function...
  50. N

    Solving an ODE with ode45 on [0,10]

    Homework Statement solve the initial problem using ode45 on the interval [0,10] Homework Equations cost dy/dt + ysint = 2t cos^2(t) y(0) = -Pi The Attempt at a Solution I have no I dia how to sart
Back
Top