From 8ac15bc5efafa2afc053c293152605b0e6ae60ff Mon Sep 17 00:00:00 2001 From: Siddharth Agarwal Date: Tue, 3 Sep 2019 18:27:40 +0530 Subject: Xcos examples from textbooks and for blocks --- .../3432/CH7/EX7.2.b/DEPENDENCIES/fig_settings.sci | 9 ++++++ Working_Examples/3432/CH7/EX7.2.b/Ex7_2.sce | 36 +++++++++++++++++++++ Working_Examples/3432/CH7/EX7.2.b/Ex7_2_f0.pdf | Bin 0 -> 17756 bytes 3 files changed, 45 insertions(+) create mode 100755 Working_Examples/3432/CH7/EX7.2.b/DEPENDENCIES/fig_settings.sci create mode 100755 Working_Examples/3432/CH7/EX7.2.b/Ex7_2.sce create mode 100755 Working_Examples/3432/CH7/EX7.2.b/Ex7_2_f0.pdf (limited to 'Working_Examples/3432/CH7/EX7.2.b') diff --git a/Working_Examples/3432/CH7/EX7.2.b/DEPENDENCIES/fig_settings.sci b/Working_Examples/3432/CH7/EX7.2.b/DEPENDENCIES/fig_settings.sci new file mode 100755 index 0000000..5d5e7d4 --- /dev/null +++ b/Working_Examples/3432/CH7/EX7.2.b/DEPENDENCIES/fig_settings.sci @@ -0,0 +1,9 @@ +//------------------------------------------------------------------ +//figure handel settings +f=get("current_figure"); //Current figure handle +f.background=8; //make the figure window background white +l=f.children(1); +l.background=8 ;//make the text background white +id=color('grey'); +xgrid(id); +//------------------------------------------------------------------ diff --git a/Working_Examples/3432/CH7/EX7.2.b/Ex7_2.sce b/Working_Examples/3432/CH7/EX7.2.b/Ex7_2.sce new file mode 100755 index 0000000..3cffa9b --- /dev/null +++ b/Working_Examples/3432/CH7/EX7.2.b/Ex7_2.sce @@ -0,0 +1,36 @@ +//Example 7.2 +//Cruise control system step response. + +xdel(winsid())//close all graphics Windows +clear; +clc; +clc; +//------------------------------------------------------------------ +//Cruise control system parameters +m=1000; +b=50; +u=500; + +// Transfer function +s=%s; // or +s=poly(0,'s'); +sys1=syslin('c',(1/m)/(s+b/m)); +disp(sys1) +//------------------------------------------------------------------ +F=[0 1; 0 -b/m]; +G=[0;1/m]; +H=[0 1]; +J=0; +sys=syslin('c',F,G,H,J); +//------------------------------------------------------------------ +//step response to u=500; +t=0:0.5:100; +v=csim('step',t,u*sys); +plot(t,v,2) + +//Title, labels and grid to the figure +exec .\fig_settings.sci; // custom script for setting figure properties +title('Responses of car velocity to a step in u','fontsize',3) +xlabel('Time t (sec.)','fontsize',2) +ylabel('Amplitude','fontsize',2) +//------------------------------------------------------------------ diff --git a/Working_Examples/3432/CH7/EX7.2.b/Ex7_2_f0.pdf b/Working_Examples/3432/CH7/EX7.2.b/Ex7_2_f0.pdf new file mode 100755 index 0000000..4b40aab Binary files /dev/null and b/Working_Examples/3432/CH7/EX7.2.b/Ex7_2_f0.pdf differ -- cgit