Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- % TO MUSI BYC DOBRZE I CHUJ
- R1 = 100;
- R2 = 100;
- C1 = 100e-6;
- C2 = 220e-6
- L = 1e-3;
- E = [R1*C1 0 L;0 R2*C2 L;C1 C2 0];
- A1 = [-1 0 0; 0 -1 0; 0 0 1];
- B1 = [1 0;0 1; 0 0];
- A=inv(E)*A1;
- B=inv(E)*B1;
- e1='5*sin(2*pi*50*t)'; %5 zamiast 10
- e2='20*sin(2*pi*50*t)';
- x0=0;
- dt=1e-5;
- t=1e-1;
- tic
- function sym_stanE2(A,B,fw1,fw2,dt,t,x0)
- maxit=t/dt;
- x=x0;
- [m,n]=size(A);
- I=eye(m,m);
- f1=inline(fw1);
- f2=inline(fw2);
- for i=1:maxit
- u1=feval(f1,i*dt);
- u2=feval(f2,i*dt);
- u=[u1;u2];
- x=(I+dt*A)*x+dt*B*u;
- xw1(i) = x(1);
- xw2(i) = x(2);
- xw3(i) = x(3);
- tw(i) = i*dt;
- end;
- figure;
- hold on;
- plot(tw, xw1, 'r')
- plot(tw, xw2, 'g')
- plot(tw, xw3, 'b')
- xlabel('t[s]')
- ylabel('U[V], I[A]')
- legend('U1', 'U2', 'I')
- hold off;
- end;
- toc
- tic
- function sym_stanE1(A,B,fw1,fw2,dt,t,x0)
- maxit=t/dt;
- x=x0;
- [m,n]=size(A);
- I=eye(m,m);
- f1=inline(fw1);
- f2=inline(fw2);
- for i=1:maxit
- u1=feval(f1,i*dt);
- u2=feval(f2,i*dt);
- u=[u1;u2];
- x=inv(I-dt*A)*(x+dt*B*u);
- xw1(i) = x(1);
- xw2(i) = x(2);
- xw3(i) = x(3);
- tw(i) = i*dt;
- end;
- figure;
- hold on;
- plot(tw, xw1, 'r')
- plot(tw, xw2, 'g')
- plot(tw, xw3, 'b')
- xlabel('t[s]')
- ylabel('U[V], I[A]')
- legend('U1', 'U2', 'I3')
- hold off;
- end;
- toc
- sym_stanE2(A,B,e1,e2,dt,t,x0)
- sym_stanE1(A,B,e1,e2,dt,t,x0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement