clc; clear all; close all; format short g global tau1 %variable global almacena la entrada del sistema ti=0; h=0.001; tf = 5; t=ti:h:tf; %vector tiempo ci=[0; 0]; %condiciones iniciales opciones=odeset('RelTol',1e-3,'InitialStep',1e-3,'MaxStep',1e-3); disp('Simulación puede demorar por funciones discontinuas......') %solución numérica del modelo dinámico del péndulo [t,x]=ode45('cap7_pendulo',t,ci,opciones); xp=cap7_pendulo(t,x,9); [m n]=size(t); q1=x(:,1); qp1=x(:,2); Ftau1=zeros(m,1); Fq1=zeros(m,1); sFq1=zeros(m,1); Fqp1=zeros(m,1); sFqp1=zeros(m,1); Fsign=zeros(m,1); Fsin=zeros(m,1); lambda=25; for k=2:m %filtros recursivos Ftau1(k)=exp(-h*lambda)*Ftau1(k-1)+(1-exp(-h*lambda))*tau1(k-1); Fq1(k)=exp(-h*lambda)*Fq1(k-1)+(1-exp(-h*lambda))*q1(k-1); sFq1(k)=-lambda*Fq1(k)+lambda*q1(k); Fqp1(k)=exp(-h*lambda)*Fqp1(k-1)+(1-exp(-h*lambda))*sFq1(k-1); sFqp1(k)=-lambda*Fqp1(k)+lambda*sFq1(k); Fsign(k)=exp(-h*lambda)*Fsign(k-1)+(1-exp(-h*lambda))*sign(sFq1(k-1)); Fsin(k)=exp(-h*lambda)*Fsin(k-1)+(1-exp(-h*lambda))*sin(q1(k-1)); end fi=[sFqp1, sFq1, Fsign, Fsin]; [r,theta] =mincuad(Ftau1,fi); theta