Definition of Caputo fractional order system

3 次查看(过去 30 天)
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