Can you help me with this task?

4 Ansichten (letzte 30 Tage)
Saba Bukhnikashvili
Saba Bukhnikashvili am 16 Jun. 2022
Beantwortet: Sam Chak am 18 Jun. 2022
x³y" + x²y' = 1 i have to write a code that solves this differential equetion? any hints or examples how to do it?

Antworten (2)

l l
l l am 16 Jun. 2022
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 am 18 Jun. 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')

Kategorien

Mehr zu Programming finden Sie in Help Center und File Exchange

Tags

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by