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...
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...
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...
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...
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 =...
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...
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...
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...
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...
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 =...
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...
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 =...
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...
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...
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...
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...
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 =...
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 τ)...
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...
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?
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...
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) -...
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!
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...
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...
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...
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...
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...
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...
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...
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...
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...
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...
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...
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...
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?
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
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...
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...
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...
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...
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...
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...
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) =...
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...
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...
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)...
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...
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