I have written a function plus a script to solve a non linear single degree of freedom pendalum system.I don't know how to solve the nonlinear equation with ODE45 function for different values of initial conditions.How could I do that?.I have used a for loop but it gives me just the state vector of the last initial condtion.I want the state vector for all initial condtions.Here are my function and the script:
function xDot = of(x,g,L,u)
xDot = zeros(2,1);
xDot(1) = x(2);
xDot(2) = ((g./L)*sin(x(1)))+u;
end
clc;clear;close all;
L = 1;
g = 9.81;
h = 0.25;
t = [0:h:5];
A = [0 1;(g/L) 0];
B =[0 1]';
Ics = [pi,0;pi/2 0;pi/5 0;0.001 0;pi 0.5;pi/2 0.5;pi/5 0.5;0.001 0.5];
[Poles,~] = eig(A);
R = 0.001;
Q = eye(2);
K = lqr(A,B,Q,R);
u = @(x)-K*(x);
for i = 1:size(Ics, 1)
[~, X] = ode45(@(t, x)of(x, g, L, u(x)), t, Ics(i, :));
end