Integrating the results of state space output(ode45)

1 view (last 30 days)
Basetsana Sebolao
Basetsana Sebolao on 19 May 2021
Answered: Torsten on 19 May 2021
Hi everyone
This is a question that I asked previously however It was not posed correctly;
I solved a state space equation using a function and 0de45, I have attached a picture of my function.
By running the below code in the command window, the plots of y(1), y(2), y(3) and y(4) are generated against time..After plotting y(1), y(2), y(3), I am trying to plot the integral functions of y(1), y(2), y(3) ...however, I am having a hard time plotting the integrals. please kindly assist, thank you in advance!
tspan = [0 0.005];
iniCon = [0; 0; 0; 0];
[t,y] = ode45(@sys, tspan, iniCon);
figure
cols = size(y,2);
for k = 1:cols
subplot(cols,1,k)
plot(t, y(:,k))
grid
xlim([0 1.5E-4])
title(sprintf('y_{%d}',k))

Answers (1)

Torsten
Torsten on 19 May 2021
Alternatively to the solution I suggested previously, you can use Matlab's "cumtrapz".

Community Treasure Hunt

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

Start Hunting!