Matlalb problem with two first order ODEs

  • Thread starter Thread starter sara_87
  • Start date Start date
  • Tags Tags
    First order Odes
Click For Summary
SUMMARY

The discussion focuses on solving two first-order ordinary differential equations (ODEs) using MATLAB. The user seeks assistance in plotting y(2) against y(1) and encounters an error when defining variables for a system of second-order ODEs. The correct MATLAB command for plotting is identified as plot(y(:,1),y(:,2)), which allows for plotting y(2) versus y(1). Additionally, the user is advised to provide the exact system of equations to resolve the error related to the definition of y(4).

PREREQUISITES
  • Understanding of first-order and second-order ordinary differential equations (ODEs)
  • Familiarity with MATLAB syntax and plotting functions
  • Knowledge of variable substitution in differential equations
  • Ability to define and solve systems of equations in MATLAB
NEXT STEPS
  • Learn MATLAB plotting functions for multidimensional data visualization
  • Study the method of substitution for converting higher-order ODEs to first-order systems
  • Explore MATLAB's ODE solvers, such as ode45, for solving differential equations
  • Review MATLAB documentation on defining and using function handles for systems of equations
USEFUL FOR

Students and professionals in mathematics, engineering, and physics who are working with ordinary differential equations and using MATLAB for numerical analysis and visualization.

sara_87
Messages
748
Reaction score
0

Homework Statement



I have two questions:
1) If i have two first order ODE y(1) and y(2) (in terms of time), i know how to plot y(1) versus time and y(2) versus time but i don't know how to plot y(2) versus y(1)

2)I have two second order ODES X''=... and Z''=... to solve this, we make the substitutions y(1)=X, y(2)=X', y(3)=Z, and y(4)=Z'
then we have two first order ODEs: y(2)'=... and y(4)'=...
I typed this into Matlab (dydt=[(the equation for y(2)'; the equation for y(4)']) but an error came up since i didnt define y(4). how do i do this?
2. Homework Equations



3. The Attempt at a Solution
1) i tried putting:
plot(y(1),y(:,2)), and i also tried plot(y(1),y(2)) but these didnt work.


Any help would be very much appreciated.
Than you.
 
Physics news on Phys.org
1) plot(y(:,1),y(:,2)) ought to work, assuming you just left out the iterate through all rows part in the first column.

2) Can you post your exact system of equations function?
 

Similar threads

  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 9 ·
Replies
9
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 11 ·
Replies
11
Views
3K
  • · Replies 3 ·
Replies
3
Views
5K