What is Causing an Error in My Matlab Code for Solving a System of Equations?

  • Context: MATLAB 
  • Thread starter Thread starter dexter90
  • Start date Start date
  • Tags Tags
    Matlab System
Click For Summary
SUMMARY

The forum discussion addresses an error encountered in a MATLAB function designed to solve a system of equations using the ODE45 solver. The primary issue identified is the lack of initial conditions for the variables y(1) and y(2) in the function kkd. The user is advised to define these initial conditions explicitly to resolve the error and ensure the function operates correctly.

PREREQUISITES
  • Understanding of MATLAB programming
  • Familiarity with ODE45 solver in MATLAB
  • Knowledge of defining functions in MATLAB
  • Basic concepts of initial conditions in differential equations
NEXT STEPS
  • Review MATLAB documentation on ODE45 for solving ordinary differential equations
  • Learn how to define and use initial conditions in MATLAB functions
  • Explore debugging techniques in MATLAB to identify and fix errors
  • Study examples of systems of equations solved using MATLAB
USEFUL FOR

MATLAB programmers, students learning numerical methods, and anyone troubleshooting errors in differential equation solvers.

dexter90
Messages
14
Reaction score
0
I have function:

Code:
function dxdy = kkd(t,y)
x=y(1);
y=y(2);
dxdy(1)=-0.02*x+x*x*y+0.01;
dxdy(2)=0.02*x-x*x*y;

next

[t,y]=ode45(@kkd,[0 4],[0 10]);

but is error... Where is error??
 
Physics news on Phys.org
you never set the initial conditions, what is y(1) and y(2)?
 
It is ok, work.

I greet.
 

Similar threads

  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 2 ·
Replies
2
Views
4K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 11 ·
Replies
11
Views
3K
  • · Replies 6 ·
Replies
6
Views
4K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 2 ·
Replies
2
Views
4K