Questions tagged [ode45]

140 questions
0
votes
1 answer

Solving nonlinear system of differential equations in matlab usin ODE45

i am trying to solve a system of nonlinear differential equation using ODE45 MATLAB , i did that many times successfully , but this time i get the following error and i really don't know what is wrong i am confused compeletly. here are the codes. %%…
ayhan
  • 1
  • 2
0
votes
1 answer

Solving Delayed Differential Equations using ode45 Matlab

I am trying to solve DDE using ode45 in Matlab. My question is about the way that I am solving this equation. I don't know if I am right or I am wrong and I should use dde23 instead. I have a following equation: xdot(t)=Ax+BU(t-td)+E(t) &…
Sina
  • 183
  • 14
0
votes
0 answers

Passing variables into a function used in ODE solver inside PARFOR

I have a ODE function which I am trying to solve multiple times with different parameters. here is the function function xdot=SB(t,x) global ps f R0 S=.0725 ; rhoL=998; vL =1.0e-3; c = 1481; pvtinf=0 ; pinf0=1.01e5; k =7/5;…
Hos
  • 1
0
votes
1 answer

MATLAB ODE45: only saving last solution

I would like to only have ODE45 retain the last solution. Rather returning the all the solutions from the tspan = [t0 tf]; I only want the returned vector to be the solution at tf. The reason why I would like to do this is to avoid the following…
kirikoumath
  • 723
  • 9
  • 20
0
votes
1 answer

How to debug this Matlab code to model glider descent?

I have this Matlab project but for some reason I just cannot stop thinking about it because I could not get it to work. Objective: This is a MATLAB script that would calculate the change of pressure, temperature and density of a glider that is being…
Gadless
  • 3
  • 1
0
votes
0 answers

ODE45 which i can not solve

I have a problem to use ODE45. I gave the matlab code below. I can not start the solver. Probably it is a syntax error. If you can find the problem i would be happy. It is a modeling and simulation of packed bed reactor. However; i get errors before…
hksdejavu
  • 65
  • 1
  • 2
0
votes
1 answer

Error when passing arguments to function handles

Suppose we have the following function: function f=lorenz(t,x,a,b,c) % solve differential equation like this %dx/dt=a*(y-x) %dy/dt=-x*z+b*x-y %dz/dt=xy-c*z/3 f=zeros(3,1);% preallocate result f(1)=a*(x(2)-x(1)); …
user466534
0
votes
0 answers

In MATLAB ode45, how do I solve a system of ODE where a parameter is dependent on other parameter, and not time dependant?

Consider the equations for a launch vehicle dv/dt = T/m - D/m - g*sin(gam) v*d(gam)/dt = -g(-v^2/W)*cos(gam) where W is a constant dh/dt = v*sin(gam). Where v represents velocity, T is thrust. My thrust values are discrete, hence i have to use…
Vin
  • 1
0
votes
0 answers

increase speed by decreasing the number of operating digits in ODE45

I am working with ODE45 and I want to force matlab to only operate with as much as 2 decimals. I have seen that is possible to do that with vpa, but it is not really working in the ODE. Any ideas? Thank you!
kumbu
  • 145
  • 2
  • 16
0
votes
0 answers

How to set the RHS when using ode45 in matlab if I have to use some parameter which depends on the solution in each time step?

y(1)' = y(2); y(2)' = [-y(1)-y(2)^2]/(y(1)+C0); y(3)' = y(3)/y(4)*y(2)*C1; y(4)' = y(2)*FF; C0, C1, C2 and C3 are Const., FF is C2*y(3)^0.5 if y(3) > 100; FF is C3*y(3)^0.5 if y(3)<=100. How to set y(4)' in this situation? I tried y(4)' =…
Ben
  • 1
  • 1
0
votes
1 answer

MATLAB ode45 function 'Too many inputs error'

My function is: function [tout, yout] = Lorenz (rho, x0) %define constants sigma = 10; beta = 8/3; %initial conditions y0 = [x0; 1; 0]; f = @(t, y) [sigma*(y(2)-y(1)); (y(1)*(rho-y(3)))-y(2); (y(1)*y(2)) - (beta*y(3))]; [tout, yout] = ode45(f, [0…
0
votes
0 answers

Matlab: ODE45+Shooting Method appear to be not working

I am trying to solve numerically three simultaneous ODE functions: dw/ds = sin(theta) dx1/ds = cos(theta) dtheta/ds = - a * cos(theta) * (w-w0) + a * sin(theta) * x1 I am solving for a column which is separated in two halves, I want to plot w…
0
votes
0 answers

Matlab ode45 is not outputting solutions for each increment specified by my "time-span" vector

I am using the following code to call a function for ODE45 to solve: [outputs]=ode45(@(t,y)ILLYAcoupled(t,y,N,w,g),(0:0.5e-3:50),y0); I am trying to get ode45 to give me values at 0.5e-3 increments between 0 and 50, which should output a solution…
zek3r
  • 11
  • 1
0
votes
1 answer

Matlab ode45 internal step

I'm having doubts at how to use ode45 since I know it uses an internal variable step size. For instance, in my particular case I have a model of ODE's and I use a sampling time of 5 minutes. Hence, inside my main simulation loop I have the following…
Aleo
  • 1
  • 1
0
votes
0 answers

MATLAB Plot depending Variable in ode

I've a problem in MATLAB. I try to plot a variable inside the ode function. I call my ode Funktion with this code: %Above is the code for the IC and constants %Initial conditions [x0, vx0, y0, vy0] IC = [x_0; w_x; y_0;…
R.Ugolini
  • 43
  • 9