Hi @Nina
It appears that you tried to simulate the undamped pendulum-like ODE with multiple initial angles.
If I'm correct, then you can fix your code like the following:
% undamped pendulum
odefcn = @(t,y) [y(2); -sin(y(1))];
% settings
y10 = [0.1 0.7 1.5 3.0]; % initial angle (in radian)
y20 = 0; % initial angular rate
tspan = [0 20];
% solving the ODE in loops
for j = 1:length(y10)
[t, y] = ode45(odefcn, tspan, [y10(j) y20]);
plot(t, y(:,1))
hold on
end
hold off
% display graph properties
grid on
legend(strcat('y_{1}(0) = ', num2str(y10')), 'location', 'Best')
xlabel({'$t$'}, 'Interpreter', 'latex')
ylabel({'$y_{1}(t)$'}, 'Interpreter', 'latex')
title({'Solutions of $\ddot{y} = - \sin(y)$, with multiple initial conditions'}, 'Interpreter', 'latex')