Adjust the phase offset when using data from 'bode'

조회 수: 101 (최근 30일)
Romain Liechti
Romain Liechti 2019년 4월 3일
댓글: Romain Liechti 2019년 4월 4일
I'm trying to look at the phase and gain margin of an openloop system. Due to presentation/publications, I had to designa function to plot my amplitude and phase response with good font, font dimensions etc. To do so, I'm using the bode function to extract the data from my state space systems. But I have a problem with a phase offset (value at 0Hz). I know we can remove it from the properties editor avalaible in the classical bode plot but is there a solution to correct it when using this syntax [mag,phase,wout] = bode(sys,w) ?

채택된 답변

Robert U
Robert U 2019년 4월 4일
Hi Romain Liechti,
if you want - as you write - stick to the bode output you should correct the phase by a reference phase shift.
% create tf
sys = tf(1,[1 0]);
% calculate frequency response using bode
w = 2*pi*logspace(log10(0.1),log10(1e5),1000);
[mag,phase,wout] = bode(sys,w);
mag = squeeze(mag);
phase = squeeze(phase);
% correct phase
w_ref = 2*pi*1; % reference is 1 Hz here, 0 works as well for DC
[~,corrPhase,~] = bode(sys,w_ref);
phase = phase-corrPhase;
Kind regards,
Robert
  댓글 수: 1
Romain Liechti
Romain Liechti 2019년 4월 4일
Thanks for the answers, that was exactly what I was looking for!
Kind regards,
Romain

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Robert U
Robert U 2019년 4월 4일
Hi Romain Liechti,
in order to customize the frequency response plot you could use bodeplot() instead of bode(). There, you can match phase as an option.
The method is described in documentation:
In difference to bode(), bodeplot() is not suitable to output system analysis data but suits as plotting tool only.
Kind regards,
Robert

카테고리

Help CenterFile Exchange에서 Plot Customization에 대해 자세히 알아보기

제품


릴리스

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by