Cannot plot negative frequencies on Nichols with recent MATLAB versions

2 次查看(过去 30 天)
Hello all, I'm having trouble plotting negative frequencies of nichols plot on my newest MATLAB version. I try specifying Nichols(sys,w) with w=[-100:0.1:-0.1 0.1:0.1:100] and it plots the expected figure with 2017a Matlab version but not with 2021b version and i cannot figure out why

采纳的回答

Paul
Paul 2023-12-15
编辑:Paul 2023-12-15
Hi lepolonais03.
Test case shows that only positive frequencies are considered, as you've obeserved.
sys = zpk(1,[2 3],4);
w=[-100:0.1:-0.1 0.1:0.1:100];
figure
nichols(sys,w)
That is odd, becasue the doc explicitly states that for this syntax:
"The vector w can contain both negative and positive frequencies."
As a workaround, you can use the output form of nichols and make the plot yourself
[mag,phase,wout] = nichols(sys,w);
figure
plot(squeeze(phase),squeeze(db(mag)))
Also, investigate nicholsplot, which might give an option to construct the plot to include negative frequencies.
Seems like bode is also not plotting in accordance with the doc.
figure
bode(sys,w)
  2 个评论
lepolonais03
lepolonais03 2023-12-16
Thank you for the solution! It seems to be all right. But yeah that's odd that the plot, even if written in the doc, does not work on recent versions!
Paul
Paul 2023-12-16
编辑:Paul 2023-12-16
It's interesting that it worked the way you say in 2017b. The online doc only goes back as far as 2018b, and in 2018b the doc page nichols 2018b does NOT explicitly say that w can have negative values. Reviewing the release notes it seems like the intent of the negative frequencies option is only to support models with complex coefficients (if that's the case, the doc page should say that explicitly).
So another workaround, which is kind of janky, would be
sys = zpk(1,[2 3],4);
format long e
[z,p,k] = zpkdata(sys);
systemp = zpk(z{:},p{:},k + 1j*eps(k))
Warning: This zpk model has a complex gain or some complex zeros or poles that do not come in conjugate pairs.
systemp = (4+8.8818e-16i) (s-1) --------------------- (s-2) (s-3) Continuous-time zero/pole/gain model.
w=[-100:0.1:-0.1 0.1:0.1:100];
figure
nichols(systemp,w)

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Plot Customization 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by