Skip to content
Snippets Groups Projects
Commit ea3c9d97 authored by JB's avatar JB
Browse files

removed test integration

parent bd8c4246
No related branches found
No related tags found
No related merge requests found
clc; clear all; close all;
%% plot multiple trajectories for the single integrator dynamics
import casadi.*
SX_x = SX.sym('x', 2, 1);
SX_u = SX.sym('u', 1, 1);
A = [0, 1; 0, 0];
B = [0; 1];
ode = struct('x', SX_x, 'p', SX_u, 'ode', A * SX_x + B * SX_u);
T = 10;
T_star = 5;
T_sample = 0.1;
tsamples = 100;
opts = struct('grid', linspace(0, T_sample, tsamples + 1));
F = integrator('F', 'cvodes', ode, opts);
grid on; hold on;
xi = [2; 0];
trajectory_vals = [xi];
for i = 1:floor(T / T_sample)
if (T_sample * i < T_star)
trajectory = F('x0', trajectory_vals(:, end), 'p', 1);
else
trajectory = F('x0', trajectory_vals(:, end), 'p', -1);
end
trajectory_vals = [trajectory_vals, full(trajectory.xf)];
end
%get the trajectory samples
plot(trajectory_vals(1, :), trajectory_vals(2, :))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment