[scilab-Users] Bode Diagram and how can I plot those functions on different graph windows ?

Serge Steer Serge.Steer at inria.fr
Mon Sep 19 17:49:03 CEST 2011


Le 19/09/2011 17:06, Reinaldo a écrit :
> / Define "s" as variable
> // (s é um polinômio de raiz zero)
> s  =  poly(0,'s');
> // Define the transfer function:
> H  =  (s)/(s+1);
> // Define the frequency range (Hz)
> f  =  0.001:0.001:100;
> // Calculate the frequency-response:
> y  =  freq(H.num,H.den,2*%pi*%i*f);
> // Calculate the absolute value function module:
> yabs  =  abs(y);
> // Calcula the function module in dB
> ym  =  20*log10(abs(y));
> // Calculate the phase function in degree:
> yf  =  (180/%pi)*atan(imag(y),  real(y));
>
> // open and clean the graph window
> xbasc(),
> // Divide the graph window in three rows:
> subplot(3,1,1),
> plot2d('ln',f,yabs,style=2),
> xgrid(),
> xtitle("Modulo em valores absolutos da Função de Transferência","Freqüência [Hz]","Módulo em dB");
> subplot(3,1,2),
> plot2d('ln',f,ym,style=2),
> xgrid(),
> xtitle("Modulo em dB da Função de Transferência","Freqüência [Hz]","Módulo em dB");
> subplot(3,1,3),
> plot2d('ln',f,yf,style=3),
> xtitle("Fase da Função de Transferência","Freqüência [Hz]","Fase em Graus");
> xgrid();

You can modify the margins properties for that
Note that you can use repfreq to compute the frequency dicretisation and 
the frequency response
the following code pllies both solutions



// Define "s" as variable
// (s é um polinômio de raiz zero)
s = poly(0,'s');
// Define the transfer function:
H = syslin('c',(s)/(s+1)); // set continuous time
[f,y]=repfreq(H,0.001,100);

// Calculate the absolute value function module:

yabs = abs(y);
// Calcula the function module in dB
ym = 20*log10(abs(y));

// Calculate the phase function in degree:
yf = (180/%pi)*atan(imag(y), real(y));

// open and clean the graph window
clf(),
// Divide the graph window in three rows:
subplot(3,1,1),
plot2d('ln',f,yabs,style=2),
ax=gca();
ax.margins(3:4)=0.24;
xgrid(),
xtitle("Modulo em valores absolutos da Função de 
Transferência","Freqüência [Hz]","Módulo em dB");

subplot(3,1,2),
plot2d('ln',f,ym,style=2),
ax=gca();
ax.margins(3:4)=0.24;
xgrid(),
xtitle("Modulo em dB da Função de Transferência","Freqüência 
[Hz]","Módulo em dB");

subplot(3,1,3),
plot2d('ln',f,yf,style=3),
xtitle("Fase da Função de Transferência","Freqüência [Hz]","Fase em Graus");
ax=gca();
ax.margins(3:4)=0.24;
xgrid();



Serge Steer
INRIA
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20110919/4bbabebb/attachment.htm>


More information about the users mailing list