# How do i code linear Ordinary differentiation?

12 visualizaciones (últimos 30 días)
mandla Tshabalala el 28 de Mzo. de 2023
Respondida: Suman Sahu el 3 de Abr. de 2023
How do i plot linear Ordinary differentiation dy/dx-y =x ........Y= -x -1+ce?
##### 0 comentariosMostrar -1 comentarios más antiguosOcultar -1 comentarios más antiguos

Iniciar sesión para comentar.

### Respuestas (1)

Suman Sahu el 3 de Abr. de 2023
Hi Mandla,
Your ordinary differential equation can be written as dy/dx = x + y. To plot the differential equation you have to first solve the equation for which you can use any of the ode solvers, eg. ode45 and then use the plot function to plot the generated solution.
Here is an example code for the given ODE.
%step 1: define the function, which is the right hand side of the equation when you write your ode in above format.
f = @(x,y)(x + y);
The ode45() function has the following syntax:
ode45(f, [Xi Xf], Yi);
where f is the equation in terms of variables x and y.
[Xi Xf] are the lower and upper limits of x for which equation will be integrated.
Yi is the initial value of the variable y.
%step 2: solve the equation, here I've assumed the parameters for this example.
[x, y] = ode45(f, [0 10], 0);
%Step 3: plot the solution
plot(x, y);
Hope it helps!
##### 0 comentariosMostrar -1 comentarios más antiguosOcultar -1 comentarios más antiguos

Iniciar sesión para comentar.

### Categorías

Más información sobre Ordinary Differential Equations en Help Center y File Exchange.

R2023a

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!