Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: Bodeplot
Replies: 0  

Advanced Search

Back to Topic List Back to Topic List  
Sascha Ziemann

Posts: 9
Registered: 12/7/04
Bodeplot
Posted: Jul 21, 1996 5:11 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

This is a multi-part message in MIME format.

--------------1E94529E1D661C1950D1A9A9
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit

Hi,

I wrote yesterday a function for Bode-Plots. Perhaps someone finds it
usefull.

-- bis später...
- Sascha ---<~>=( http://www.ping.de/sites/aibon/ )=<~>---

() Free speech online
/\ http://www.eff.org/BlueRibbon/bluehtml.html

--------------1E94529E1D661C1950D1A9A9
Content-Type: text/plain; charset=iso-8859-1; name="bodeplot.m"
Content-Transfer-Encoding: 8bit
Content-Disposition: inline; filename="bodeplot.m"

function bodeplot( w, g, wc, pt, f1, f2 );
%
% Bode-Diagramm
%
% function bodeplot( w, g, wc, pt, f1, f2 );
%
% w: Vektor mit Frequenzwerten
% g: Vektor mit Funktionswerten (komplex)
% wc: Grenzfrequenz
% pt: Plottyp 1: ein Diagramm
% 2: zwei Diagramme in einer Figure
% 3: zwei Diagramme in zwei FIgures
%
% 96/07/20 Sascha Ziemann szi@aibon.ping.de
%

if nargin == 3
pt = 1;
f1 = figure;
end

if nargin == 4
if pt == 2
f1 = figure;
elseif pt == 3
f1 = figure;
f2 = figure;
end
end

if nargin == 5
if pt == 3
f2 = figure;
end
end

a = 20 * log(abs(g)); % Betrag in dB

figure(f1);
clf;
if pt == 2
subplot(2,1,1);
end
semilogx(w,a);
grid on;
[tmp,x] = min(abs(a)); % Stelle der Durchtrittsfrequenz
[tmp,y] = min(abs(w-wc)); % Stelle der Grenzfrequenz
ylabel('Betrag in dB');
title1 = sprintf('w_0 = %2.2f w_c = %2.1f |G(w_c)| = %3.1fdB',...
w(x), wc, a(y));
title(title1);
hold on;
stem([w(x), wc], [0, a(y)]);

p = angle(g)./pi.*180; % Phase

if pt == 2
subplot(2,1,2);
elseif pt == 3
figure(f2);
clf;
end

semilogx(w,p);
grid on;
if pt == 1
ylabel('Phase in ° Betrag in dB');
else
ylabel('Phase in °');
end
title2 = sprintf('Phi_r(w_0) = %2.2f Phi_r(w_c) = %2.2f',...
p(x)+180, p(y)+180);
if pt == 1
title([title1 ,' ', title2]);
else
title(title2);
end

line([w(x), w(x)], [-180, p(x)]);
line([wc, wc], [-180, p(y)]);
line([w(1), w(length(w))], [-180, -180]);

--------------1E94529E1D661C1950D1A9A9
Content-Type: text/plain; charset=iso-8859-1; name="bodeps.m"
Content-Transfer-Encoding: 8bit
Content-Disposition: inline; filename="bodeps.m"

function bodeps( fkt, wc, pt, f1, f2 );
%
% Bodediagramm mit Funktion in s
%
% function bodeps( fkt, wc, f1, f2 );
%
% fkt: Funktion in s
% wc: Grenzfrequenz (wird nur an bodeplot weitergereicht)
% f1: Figure für Betrag (wird nur an bodeplot weitergereicht)
% f2: Figure für Phase (wird nur an bodeplot weitergereicht)
%
% 96/07/20 Sascha Ziemann szi@aibon.ping.de
%

fkt = strrep(fkt, 'sin', 'Sin');
fkt = strrep(fkt, '*', '.*');
fkt = strrep(fkt, '/', './');
fkt = strrep(fkt, '^', '.^');
fkt = strrep(fkt, 's', '(w*j)');

w = 0.01:0.01:100;

if nargin == 2
bodeplot(w, eval(fkt), wc);
elseif nargin == 3
bodeplot(w, eval(fkt), wc, pt);
elseif nargin == 4
bodeplot(w, eval(fkt), wc, pt, f1);
elseif nargin == 5
bodeplot(w, eval(fkt), wc, pt, f1, f2);
end


--------------1E94529E1D661C1950D1A9A9
Content-Type: text/plain; charset=iso-8859-1; name="bodetest.m"
Content-Transfer-Encoding: 8bit
Content-Disposition: inline; filename="bodetest.m"

%
% Dies ist ein Beispiel für die Benutzung der bodeplot-Funktion
%
% 96/07/20 Sascha Ziemann szi@aibon.ping.de
%

bodeps('10*2*(s+.5)/(s^3+s^2+s)', 2, 1, 1);


--------------1E94529E1D661C1950D1A9A9--





Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.