Email: helpdesk@telkomuniversity.ac.id

This Portal for internal use only!

  • My Download
  • Checkout
Application Package Repository Telkom University
All Categories

All Categories

  • Visual Paradigm
  • IBM
  • Adobe
  • Google
  • Matlab
  • Microsoft
    • Microsoft Apps
    • Analytics
    • AI + Machine Learning
    • Compute
    • Database
    • Developer Tools
    • Internet Of Things
    • Learning Services
    • Middleware System
    • Networking
    • Operating System
    • Productivity Tools
    • Security
    • VLS
      • Office
      • Windows
  • Opensource
  • Wordpress
    • Plugin WP
    • Themes WP
  • Others

Search

0 Wishlist

Cart

Categories
  • Microsoft
    • Microsoft Apps
    • Office
    • Operating System
    • VLS
    • Developer Tools
    • Productivity Tools
    • Database
    • AI + Machine Learning
    • Middleware System
    • Learning Services
    • Analytics
    • Networking
    • Compute
    • Security
    • Internet Of Things
  • Adobe
  • Matlab
  • Google
  • Visual Paradigm
  • WordPress
    • Plugin WP
    • Themes WP
  • Opensource
  • Others
More Categories Less Categories
  • Get Pack
    • Product Category
    • Simple Product
    • Grouped Product
    • Variable Product
    • External Product
  • My Account
    • Download
    • Cart
    • Checkout
    • Login
  • About Us
    • Contact
    • Forum
    • Frequently Questions
    • Privacy Policy
  • Forum
    • News
      • Category
      • News Tag

iconTicket Service Desk

  • My Download
  • Checkout
Application Package Repository Telkom University
All Categories

All Categories

  • Visual Paradigm
  • IBM
  • Adobe
  • Google
  • Matlab
  • Microsoft
    • Microsoft Apps
    • Analytics
    • AI + Machine Learning
    • Compute
    • Database
    • Developer Tools
    • Internet Of Things
    • Learning Services
    • Middleware System
    • Networking
    • Operating System
    • Productivity Tools
    • Security
    • VLS
      • Office
      • Windows
  • Opensource
  • Wordpress
    • Plugin WP
    • Themes WP
  • Others

Search

0 Wishlist

Cart

Menu
  • Home
    • Download Application Package Repository Telkom University
    • Application Package Repository Telkom University
    • Download Official License Telkom University
    • Download Installer Application Pack
    • Product Category
    • Simple Product
    • Grouped Product
    • Variable Product
    • External Product
  • All Pack
    • Microsoft
      • Operating System
      • Productivity Tools
      • Developer Tools
      • Database
      • AI + Machine Learning
      • Middleware System
      • Networking
      • Compute
      • Security
      • Analytics
      • Internet Of Things
      • Learning Services
    • Microsoft Apps
      • VLS
    • Adobe
    • Matlab
    • WordPress
      • Themes WP
      • Plugin WP
    • Google
    • Opensource
    • Others
  • My account
    • Download
    • Get Pack
    • Cart
    • Checkout
  • News
    • Category
    • News Tag
  • Forum
  • About Us
    • Privacy Policy
    • Frequently Questions
    • Contact
Home/Matlab/Issues solving a system of 2, second order, differential equations with ode45

Issues solving a system of 2, second order, differential equations with ode45

PuTI / 2025-01-29
Issues solving a system of 2, second order, differential equations with ode45
Matlab News

Hello everybody,
I am starting with Matlab to solve a system of 2 differential equations, second order.
My code is below. It works, but the output is totally wrong.
This code is something taken on matlab help center and adapted to my problem, to help me start.
I have written things in the code "#comment " where it’s not clear to me.
Your help would be very helpful to me.
Thanks a lot in advance.

clear all;
close all;

syms x(t) y(t)

%% Constants
Cd = 0,45 ;% drag coef aircraft [-]
Af = 2 ;% reference area aircraft [-]
m = 10 ;% total mass aircraft [kg]
g = 9.81 ;% acc° of gravity [m/s2]
Teta = 85 ;% launch angle [deg]
V0 = 83 ;% launch velocity [m/s]
rho_Air = 1,2 ;% air density [kg/m3]
t0 = 0; ;% time interval, initial t [s]
tf = 5400 ;% time interval, final t [s]

%% Initial Conditions
x_to = 0 ;% x(t=0)= 0 [m]
dx_t0 = V0*cosd(Teta) ;% x'(t=0)= V0*cosd(Teta) [m/s]
y_to = 0 ;% y'(t=0)= 0 [m]
dy_t0 = V0*sind(Teta) ;% x(t=0)= 0 [m/s]
y0 = [x_to dx_t0 y_to dy_t0 ] ;% vector initial conditions

%% System differential equations to be solved
eq1 = diff(x,2) == -( (Cd*Af*rho_Air)/(2*m) ) * diff(x,1) * (x^2 + y^2)^(1/2)
eq2 = diff(y,2) == – g – ( (Cd*Af*rho_Air)/(2*m) ) * diff(y,1) * ( (diff(x,1))^2 + (diff(y,1))^2 )^(1/2)

%% variables
vars = [x(t); y(t)]

V = odeToVectorField([eq1,eq2])
M = matlabFunction(V,’vars’, {‘t’,’Y’});
% #comment: why the variable x doesn’t appear here ? as I solve on x(t) and
% y(t) -> in V I call eq1 and eq2, then it’s x(t) and y(t)

interval = [t0 tf]; %time interval

ySol = ode45(M,interval,y0);
% #comment: vector y0 containts the boundary conditions for both x and y.
% As here I solve on y, why do we have boundary conditions in x as well ?
% is the function ode capable to make the difference in between boudady
% conditions for x and y ?
tValues = linspace(interval(1),interval(2),1000);
yValues = deval(ySol,tValues,1); %number 1 denotes first position likewise you can mention 2 to 6 for the next 5 positions

plot(tValues,yValues) %if you want to plot position vs time just swap here

% #comment: I need to solve on x as well
% thank you !Hello everybody,
I am starting with Matlab to solve a system of 2 differential equations, second order.
My code is below. It works, but the output is totally wrong.
This code is something taken on matlab help center and adapted to my problem, to help me start.
I have written things in the code "#comment " where it’s not clear to me.
Your help would be very helpful to me.
Thanks a lot in advance.

clear all;
close all;

syms x(t) y(t)

%% Constants
Cd = 0,45 ;% drag coef aircraft [-]
Af = 2 ;% reference area aircraft [-]
m = 10 ;% total mass aircraft [kg]
g = 9.81 ;% acc° of gravity [m/s2]
Teta = 85 ;% launch angle [deg]
V0 = 83 ;% launch velocity [m/s]
rho_Air = 1,2 ;% air density [kg/m3]
t0 = 0; ;% time interval, initial t [s]
tf = 5400 ;% time interval, final t [s]

%% Initial Conditions
x_to = 0 ;% x(t=0)= 0 [m]
dx_t0 = V0*cosd(Teta) ;% x'(t=0)= V0*cosd(Teta) [m/s]
y_to = 0 ;% y'(t=0)= 0 [m]
dy_t0 = V0*sind(Teta) ;% x(t=0)= 0 [m/s]
y0 = [x_to dx_t0 y_to dy_t0 ] ;% vector initial conditions

%% System differential equations to be solved
eq1 = diff(x,2) == -( (Cd*Af*rho_Air)/(2*m) ) * diff(x,1) * (x^2 + y^2)^(1/2)
eq2 = diff(y,2) == – g – ( (Cd*Af*rho_Air)/(2*m) ) * diff(y,1) * ( (diff(x,1))^2 + (diff(y,1))^2 )^(1/2)

%% variables
vars = [x(t); y(t)]

V = odeToVectorField([eq1,eq2])
M = matlabFunction(V,’vars’, {‘t’,’Y’});
% #comment: why the variable x doesn’t appear here ? as I solve on x(t) and
% y(t) -> in V I call eq1 and eq2, then it’s x(t) and y(t)

interval = [t0 tf]; %time interval

ySol = ode45(M,interval,y0);
% #comment: vector y0 containts the boundary conditions for both x and y.
% As here I solve on y, why do we have boundary conditions in x as well ?
% is the function ode capable to make the difference in between boudady
% conditions for x and y ?
tValues = linspace(interval(1),interval(2),1000);
yValues = deval(ySol,tValues,1); %number 1 denotes first position likewise you can mention 2 to 6 for the next 5 positions

plot(tValues,yValues) %if you want to plot position vs time just swap here

% #comment: I need to solve on x as well
% thank you ! Hello everybody,
I am starting with Matlab to solve a system of 2 differential equations, second order.
My code is below. It works, but the output is totally wrong.
This code is something taken on matlab help center and adapted to my problem, to help me start.
I have written things in the code "#comment " where it’s not clear to me.
Your help would be very helpful to me.
Thanks a lot in advance.

clear all;
close all;

syms x(t) y(t)

%% Constants
Cd = 0,45 ;% drag coef aircraft [-]
Af = 2 ;% reference area aircraft [-]
m = 10 ;% total mass aircraft [kg]
g = 9.81 ;% acc° of gravity [m/s2]
Teta = 85 ;% launch angle [deg]
V0 = 83 ;% launch velocity [m/s]
rho_Air = 1,2 ;% air density [kg/m3]
t0 = 0; ;% time interval, initial t [s]
tf = 5400 ;% time interval, final t [s]

%% Initial Conditions
x_to = 0 ;% x(t=0)= 0 [m]
dx_t0 = V0*cosd(Teta) ;% x'(t=0)= V0*cosd(Teta) [m/s]
y_to = 0 ;% y'(t=0)= 0 [m]
dy_t0 = V0*sind(Teta) ;% x(t=0)= 0 [m/s]
y0 = [x_to dx_t0 y_to dy_t0 ] ;% vector initial conditions

%% System differential equations to be solved
eq1 = diff(x,2) == -( (Cd*Af*rho_Air)/(2*m) ) * diff(x,1) * (x^2 + y^2)^(1/2)
eq2 = diff(y,2) == – g – ( (Cd*Af*rho_Air)/(2*m) ) * diff(y,1) * ( (diff(x,1))^2 + (diff(y,1))^2 )^(1/2)

%% variables
vars = [x(t); y(t)]

V = odeToVectorField([eq1,eq2])
M = matlabFunction(V,’vars’, {‘t’,’Y’});
% #comment: why the variable x doesn’t appear here ? as I solve on x(t) and
% y(t) -> in V I call eq1 and eq2, then it’s x(t) and y(t)

interval = [t0 tf]; %time interval

ySol = ode45(M,interval,y0);
% #comment: vector y0 containts the boundary conditions for both x and y.
% As here I solve on y, why do we have boundary conditions in x as well ?
% is the function ode capable to make the difference in between boudady
% conditions for x and y ?
tValues = linspace(interval(1),interval(2),1000);
yValues = deval(ySol,tValues,1); %number 1 denotes first position likewise you can mention 2 to 6 for the next 5 positions

plot(tValues,yValues) %if you want to plot position vs time just swap here

% #comment: I need to solve on x as well
% thank you ! solving ode, ode45, system 2 ode second order MATLAB Answers — New Questions

​

Tags: matlab

Share this!

Related posts

Optimal decimation to Log Simulation Data
2025-05-18

Optimal decimation to Log Simulation Data

I need to use a scope to display the current i and the power P as functions of the voltage V, with the curves obtained for various irradiance levels and temperatures
2025-05-18

I need to use a scope to display the current i and the power P as functions of the voltage V, with the curves obtained for various irradiance levels and temperatures

Break in and break away points on Root Locus
2025-05-18

Break in and break away points on Root Locus

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Search

Categories

  • Matlab
  • Microsoft
  • News
  • Other
Application Package Repository Telkom University

Tags

matlab microsoft opensources
Application Package Download License

Application Package Download License

Adobe
Google for Education
IBM
Matlab
Microsoft
Wordpress
Visual Paradigm
Opensource

Sign Up For Newsletters

Be the First to Know. Sign up for newsletter today

Application Package Repository Telkom University

Portal Application Package Repository Telkom University, for internal use only, empower civitas academica in study and research.

Information

  • Telkom University
  • About Us
  • Contact
  • Forum Discussion
  • FAQ
  • Helpdesk Ticket

Contact Us

  • Ask: Any question please read FAQ
  • Mail: helpdesk@telkomuniversity.ac.id
  • Call: +62 823-1994-9941
  • WA: +62 823-1994-9943
  • Site: Gedung Panambulai. Jl. Telekomunikasi

Copyright © Telkom University. All Rights Reserved. ch

  • FAQ
  • Privacy Policy
  • Term

This Application Package for internal Telkom University only (students and employee). Chiers... Dismiss