Borrar filtros
Borrar filtros

Definition of Caputo fractional order system

3 visualizaciones (últimos 30 días)
Farshid R
Farshid R el 7 de Sept. de 2022
Respondida: Anurag Ojha el 12 de Jun. de 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.

Respuestas (1)

Anurag Ojha
Anurag Ojha el 12 de Jun. de 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.

Categorías

Más información sobre Programming en Help Center y File Exchange.

Productos


Versión

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by