Está en la página 1de 1

Primer Punto

Para la funcin
function xdot=simpode(t,x);
xdot=x+t;

Para el programa
tspan=[0 2]; %tiempo de simulacin
x0=0;
[t,x]=ode23('simpode',tspan,x0); %se llama la funcin para evaluar las
derivadas

plot(t,x)
xlabel('t')
ylabel('x')

Segundo Punto: pendulo

Para la funcin
function xdot=pend(t,x);
%x(1) es la primera variable de estado que representa la posicin
angular
%x(2) representa la segunda variable de estado la velocidad angular
%x=[x(1);x(2)]=[theta y theta_dot]
%out es xdot=[x(2);w2sinx(1)]
wsq=1.56;
xdot=[x(2);-wsq*sin(x(1))];

Para el programa
tspan=[0 7];
x0=[1;0]; %la posicin x son 2 valores, la posicin y la velocidad
[t,x]=ode23('pend',tspan,x0);
theta=x(:,1);
theta_dot=x(:,2);
plot(t,theta,t,theta_dot);
grid on;
legend('thetha','theta_(dot)')
xlabel('t');
ylabel('tetha y theta_dot');
figure
plot(theta,theta_dot);
title ('phase plane')
xlabel('posicin angular');
ylabel('velocidad');

También podría gustarte