Вы находитесь на странице: 1из 4

Table of Contents

Presentacion .......................................................................................................................
Definir Constantes que se usarn ...........................................................................................
Inicializar variables .............................................................................................................
condiciones iniciales ............................................................................................................
lazo ...................................................................................................................................
graficos .............................................................................................................................

1
1
1
1
1
2

Presentacion
%JORGE NINAZUNTA
%FECHA: 16/10/2015
%SIMULACION-SISTEMA DE ELECTROMECNICO
clc
clear all

Definir Constantes que se usarn


R=1; C=2; L=2;
k1=1;
k2=1;
k=1;
b=0.5;
M=1;
u=5; %% si varia en t, vector
tf=50; %% tiempo final (para variar facilmente)
A=[-1/(R*C) -1/C 0 0;1/L 0 0 -k1/L;0 0 0 1;0 k2/M -k/M -b/M];
B=[1/(R*C);0;0;0];
C=[0 0 1 0];
D=0;
T=0.1;
t=0:T:tf;

Inicializar variables
x=zeros(4,size(t,2)); %%size(C,1) -> numero de filas
y=zeros(size(C,1),size(t,2)); %%size(C,1)->indica el numero de salidas del sistema

condiciones iniciales
x(:,1)=[0;0;0;0];
y(:,1)=C*x(:,1)+D*u;

lazo
for i=1:size(t,2)-1

x(:,i+1)=x(:,i)+T.*(A*x(:,i)+B*u);%%tomar en cuenta el numero de operaciones ne


y(:,i+1)=C*x(:,i+1)+D*u;
end

graficos
figure(1)
plot(t,x(1,:),t,x(2,:),'.',t,x(3,:),'r--o',t,x(4,:),'y','LineWidth',2)
legend('Voltaje en Capacitor','Corriente Inductor','Desplazamiento X','Velocidad')
xlabel('tiempo')
ylabel('estados')
figure(2)
plot(t,y(1,:),'LineWidth',5)
legend('Desplazamiento X')
figure(3)
plot(x(1,:),x(2,:))
xlabel('Voltaje en Capacitor')
ylabel('Corriente Inductor')
title('Trayectoria 1')
figure(4)
plot(x(3,:),x(4,:),'r')
xlabel('Desplazamiento X')
ylabel('Velocidad')
title('Trayectoria 2')

Published with MATLAB R2013b

Вам также может понравиться