Graphics Incompatibilities in Control System Toolbox between R2024a and R2024b
이전 댓글 표시
A1 = 1; wp1 = 10;
A2 = -2; wp2 = 20;
s = tf('s');
H1 = A1 / (1 + s/wp1); H2 = A2 / (1 + s/wp2);
H = H1 + H2;
figure;
bp = bodeplot(H, H1, H2);
hLines = findobj(gcf, Type='line');
set(hLines, LineWidth=2); % not working in R2024b?
set(hLines(6), LineWidth=6, DisplayName='H2'); % not working in R2024b?
set(hLines(3), LineWidth=6, DisplayName='H2'); % not working in R2024b?
set(findall(gcf, 'Type', 'axes'), LineWidth=1.5, Box="off", fontsize=12); % not working in R2024b?
% Any correct/equivalent/recommended practice in R2024b?
figure;
pzmap(H, H1, H2);
set(gca, YTick=[], Box="off", LineWidth=1.5, XAxisLocation='origin', YAxisLocation='origin');
% get an R2024b Error using controllib.chart.PZPlot/set Unrecognized property YTick for class PZPlot.
% Any correct/equivalent/recommended practice in R2024b?
R2024a:

R2024b:

The "Version History" of "BodePlot" and "PZPlot" does point out changes in "gca", but for the "Chart Object" mentioned in it, I Googled it and couldn't find the relevant documentation, so I don't know how to get axes from Chart Object. Since the R2024b version is too new, I don't know where to find the information.
댓글 수: 4
Rarity Brown
2024년 9월 26일
Andrew Ouellette
2024년 9월 27일
To be clear: this is not a bug. Everything in my answer which relies on "findall" is not supported, and will only work for that instance of the chart. Settings changed this way will not be reflected in the Live Editor or when saving and loading the chart. That being said, we may add support for some of these options in the future.
Rarity Brown
2024년 9월 27일
편집: Rarity Brown
2024년 9월 27일
Andrew Ouellette
2024년 9월 27일
Unforunately, this is a result of control plots being more permissive of undocumented behaviors before R2024b. Workflows including "findobj" and "findall" happened to work with the plots before R2024b, but this behavior was never documented. With the switch to charts in R2024b, many workflows including "findobj" and "findall" still work for standalone charts; however, these workflows cannot be serialized by charts, and are therefore lost during save/load operations and while using the Live Editor.
채택된 답변
추가 답변 (2개)
Madheswaran
2024년 9월 13일
편집: Madheswaran
2024년 9월 13일
Hi,
As you can notice, while running in MATLAB R2024b, the `findobj` function returns only six lines: three with the tag `BodeMagnitudeLine` and three with the tag `BodePhaseLine`. So, to change the ‘LineWidth’ and ‘DisplayName’ of the desired line, you can change the indexing used in ‘hLines’ array as shown below:
% ... existing code
figure;
bp = bodeplot(H, H1, H2);
hLines = findobj(gcf, Type='line');
set(hLines, LineWidth=2);
set(hLines(1), LineWidth=6, DisplayName='H');
set(hLines(4), LineWidth=6, DisplayName='H');
set(findall(gcf, 'Type', 'axes'), LineWidth=1.5, Box="off", fontsize=12);
Similarly, in the context of `pzmap`, the `gca` function now returns a `PZPlot` chart object instead of an axes object within the plot. Since 'YTick' is not a property of 'PZPlot', the error appears. You can access the axes by indexing the children of 'PZPlot' object as demosntrated below:
figure;
pzmap(H, H1, H2);
set(gca().Children(1), YTick=[], Box="off", LineWidth=1.5, XAxisLocation='origin', YAxisLocation='origin')
Using MATLAB R2024b, the code above will produce the expected plot as shown below:

Please refer to the following MathWorks documentations on the following topics:
- pzmap - https://mathworks.com/help/control/ref/lti.pzmap.html
- bodeplot - https://mathworks.com/help/ident/ref/controllib.chart.bodeplot.html
- PZPlot - https://mathworks.com/help/control/ref/controllib.chart.pzplot.html
Hope this helps!
카테고리
도움말 센터 및 File Exchange에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!








