Загрузка...

A Step-by-Step Guide to Solve First-Order ODEs in MATLAB

In this video, you will learn how to use the ode45 command of MATLAB to solve a first-order ordinary differential equation (ODE). An illustrative example of an one-dimensional first-order ODE is presented to demonstrate the solution.

The ode45 is a function that uses a version of the Runge-Kutta method to solve ODEs. The "45" in the function name refers to the fact that the method uses 4th-order and 5th-order accurate steps to solve the ODE.

Video Sections:
0:00 Introduction
1:12 Example (one initial condition)
5:25 Example (various initial conditions)

%-------- MATLAB CODE ---------%

%% Clear and close
clc; clear; close all;

%% dx/dt = -t^4*x + x, where t = [0,5] and x(0) = 4

% define the function f
f = @(t,x)(-t^4*x + x);

% tSpan
tspan = [0,5];

% x initial condition
x0 = 4;

% multiple initial condition
%x0 = -5:5;

% ode45 command
[t,x] = ode45(f,tspan,x0);

% plot
plot(t,x)
xlabel('t');
ylabel('x');

#MATLAB #calculus #coding

Видео A Step-by-Step Guide to Solve First-Order ODEs in MATLAB канала PhD Jorge Ricardo Jr
Яндекс.Метрика
Все заметки Новая заметка Страницу в заметки
Страницу в закладки Мои закладки
На информационно-развлекательном портале SALDA.WS применяются cookie-файлы. Нажимая кнопку Принять, вы подтверждаете свое согласие на их использование.
О CookiesНапомнить позжеПринять