[matlab] codes-c-systems
Viewer
- %time vs voltage subplot for sin and cos wave subplot and exp cos wave
- clc
- clear all
- f=50;
- tp=1/f;
- fs=1000;
- ts=1/fs;
- t=0:ts:3*tp;
- x=cos(2*pi*f*t);
- subplot(3,1,1);
- plot(t,x);
- grid on
- title('cos wave');
- xlabel('time(s)');
- ylabel('voltage(v)');
- x2=sin(2*pi*f*t);
- subplot(3,1,2)
- plot(t,x2);
- grid on
- title('sin wave');
- xlabel('time(s)');
- ylabel('voltage(v)');
- %exponential plot for at
- clc
- clear all
- a=10;
- f=50;
- tp=1/f;
- fs=1000;
- ts=1/fs;
- t=0:ts:3*tp;
- x=exp(a*t).*cos(2*pi*f*t);
- subplot(3,1,3);
- plot(t,x);
- title('exponential cos wave')
- xlabel('time(s)')
- ylabel('voltage(v)')
- %impulse and step response while keeping tf=25/s^2+5s+25
- sys=tf([0 0 25],[1 5 25]);
- subplot(2,1,1)
- impulse(sys);
- subplot(2,1,2);
- step(sys);
- %exp 3
- clc
- clear all
- sys=tf([0 0 25],[1 5 25]);
- stepinfo(sys)
- ltiview(sys)
- %exp 4
- clc
- clear all
- g1=tf([0 0 1],[1 25 1]);
- h=tf([0 1 2],[0 0 1]);
- g2=tf([0 1 1],[0 0 2]);
- f=feedback(g1,h,-1);
- ltiview(f);
- %exp 5
- %to design a feedback controller for a open loop system given by
- %g(s)=s+7/s(s-5)(s+15)(s+20) such that the overshoot is 5% and risetime is
- %1 sec and unity feedback
- clc
- clear all
- z=-7;
- p=[0;5;-15;-20];
- k=1;
- g=zpk(z,p,k);
- g
- rlocus(g)
- zeta=0.7;
- w=1.8;
- sgrid(zeta,w);
- [k,poles]=rlocfind(g);
- h=feedback(g*k,1,-1);
- stepinfo(h);
- ltiview(h);
- %exp 6
- %to design a feedback controller for a open loop system given by
- %g(s)=s+7/s(s-5)(s+15)(s+20) such that the overshoot is 5% and risetime is
- %1 sec and unity feedback
- clc
- clear all
- z=-7;
- p=[0;5;-15;-20];
- k=1;
- g=zpk(z,p,k);
- g
- rlocus(g)
- zeta=0.7;
- w=1.8;
- sgrid(zeta,w);
- [k,poles]=rlocfind(g);
- h=feedback(g*k,1,-1);
- stepinfo(h);
- ltiview(h);
Editor
You can edit this paste and save as new:
File Description
- codes-c-systems
- Paste Code
- 28 Apr-2024
- 1.68 Kb
You can Share it:
Latest Code Pastes