Definition of Caputo fractional order system

조회 수: 4 (최근 30일)
Farshid R
Farshid R 2022년 9월 7일
답변: Anurag Ojha 2024년 6월 12일
Hello,
I want to code this Caputo fractional order dynamics please guide me to do this in matlab. Of course it can be done with simulink but I want to code it.
Thank you in advance for your help.

답변 (1개)

Anurag Ojha
Anurag Ojha 2024년 6월 12일
Hi Frashid
In order to code this in MATLAB you can refer to the code attached below,I have taken certain assumptions. Kindly modify it according to your use case:
% Parameters
A = [2 0; -1 -2];
B = [1 0; 0 1];
alpha = 0.9;
% Time vector
t = 0:0.01:10;
% Initial condition
x0 = [0; 0];
u = [1; 1];
% Preallocate memory for state vector
x = zeros(2, length(t));
x(:, 1) = x0;
% Compute dynamics
for i = 2:length(t)
dt = t(i) - t(i-1);
dx = A*x(:, i-1) + B*u;
x(:, i) = x(:, i-1) + dt^alpha*dx;
end
% Plot results
figure;
plot(t, x(1, :), 'b', 'LineWidth', 2);
hold on;
plot(t, x(2, :), 'r', 'LineWidth', 2);
xlabel('Time');
ylabel('State');
legend('x_1', 'x_2');
The code above defines the system matrices A and B, the fractional order alpha, and the time vector t. It then initializes the state vector x and computes the dynamics using a loop. Finally, it plots the results.

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by