Azzera filtri
Azzera filtri

Definition of Caputo fractional order system

3 visualizzazioni (ultimi 30 giorni)
Farshid R
Farshid R il 7 Set 2022
Risposto: Anurag Ojha il 12 Giu 2024
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.

Risposte (1)

Anurag Ojha
Anurag Ojha il 12 Giu 2024
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.

Categorie

Scopri di più su Programming in Help Center e File Exchange

Prodotti


Release

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by