Can you help me with this task?

x³y" + x²y' = 1 i have to write a code that solves this differential equetion? any hints or examples how to do it?

Respuestas (2)

l l
l l el 16 de Jun. de 2022

0 votos

You need to convert the n-th order ODE equation into a system of n first-order ODE equations. See https://www.mathworks.com/help/matlab/ref/ode45.html#bu3uj8b
Sam Chak
Sam Chak el 18 de Jun. de 2022
As a beginner, maybe you can do something like this in just 3 simple steps:
  1. Write a system of first-order ODEs as anonymous functions.
  2. Solve ODEs using ode45 with the specified x range and initial condition.
  3. Plot the system response.
Simulation begins from to .
Initial condition is chosen as to .
% Step 1: create anonymous function handle
f1 = @(x, y) y(2); % y₁' = y₂
f2 = @(x, y) (1 - (x^2)*y(2))/x^3; % y₂' = (1 - x²·y₂)/x³, ... rearranged from x³·y" + x²·y' = 1
% Step 2: solve ODEs using ode45 solver
[x, y] = ode45(@(x, y) ([f1(x, y); f2(x, y)]), [1 10], [0 0]); % singularity occurs at x = 0
% Step 3: plot and labels
plot(x, y, 'linewidth', 1.5), grid on, xlabel('x'), ylabel('y'), title('y vs. x')

Categorías

Más información sobre Programming en Centro de ayuda y File Exchange.

Productos

Etiquetas

Preguntada:

el 16 de Jun. de 2022

Respondida:

el 18 de Jun. de 2022

Community Treasure Hunt

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

Start Hunting!

Translated by