How can I set linewidth directly in bode command?

261 ビュー (過去 30 日間)
byungkeuk cho
byungkeuk cho 2020 年 3 月 25 日
コメント済み: Andrew Ouellette 2025 年 1 月 27 日 20:51
I can draw a bode plot as below
sys = tf(4,[1 0.5 4]);
figure(1), bode(sys), grid on;
Now, I would like to change some options in the Bode plot.
I can set the options through 'bodeoptions' as below.
sys = tf(4,[1 0.5 4]);
options = bodeoptions;
options.FreqUnits = 'Hz';
options.Title.FontSize = 14;
options.XLabel.FontSize = 14;
options.YLabel.FontSize = 14;
options.TickLabel.FontSize = 14;
figure(2), bode(sys, options), grid on;
But I can't find the option to set the linewidth of the bode plot.
How can I do that?

回答 (4 件)

Birdman
Birdman 2020 年 3 月 25 日
You can try semilogx. See the following code:
sys=tf(4,[1 0.5 4]);
[mag,phase,wout] = bode(sys);
Mag=20*log10(mag(:));Phase=phase(:);
figure(1);semilogx(wout,Mag,'LineWidth',5);grid on;
figure(2);semilogx(wout,Phase,'LineWidth',1);grid on;
  1 件のコメント
byungkeuk cho
byungkeuk cho 2020 年 3 月 25 日
Thank you for your answer.
I thought of this way but I wanted to know if I can do the same thing with bode options.
Really appreciate it though.

サインインしてコメントする。


Siddharth Jawahar
Siddharth Jawahar 2024 年 6 月 19 日
Hello Byungkeuk,
Here is an example script to demonstrate how you can adjust the linewidth of a bode plot.
sys = tf([4, 1], [0.5, 4]); % Define the system transfer function
figure(1);
[mag,phase,wout] = bode(sys); % Store Bode plot data
h = bodeplot(sys); % Plot Bode diagram
grid on;
% Get the line handles
hline = findall(gcf, 'type', 'line');
% Set the linewidth
set(hline, 'LineWidth', 2); % Change 2 to your desired linewidth
Hope this helps,
Sid
  3 件のコメント
Andrew Ouellette
Andrew Ouellette 2024 年 11 月 28 日
Note: Sid's answer is only applicable for releases prior to R2024b. Follow my answer starting in release R2024b.
Julius
Julius 2024 年 11 月 28 日
I used R2021b to create the chart I posted.
So it doesn't increase the linewidth inside the legend using his code and adding:
legend("TF")
But I will maybe upgrade to R2024b to use the charts API

サインインしてコメントする。


Andrew Ouellette
Andrew Ouellette 2024 年 11 月 28 日
For releases prior to R2024b, see Sid's answer. Starting in R2024b, you can set the line width using the chart API.
sys = tf(4,[1 0.5 4]);
h = bodeplot(sys);
h.Responses(1).LineWidth = 5;
h.LegendVisible = true;
  2 件のコメント
Jan
Jan 2025 年 1 月 27 日 20:05
Hello Andrew
I just opened a question on a similar topic over here. Is it correct, that I cannot change the properties directly anymore?
How would I change the line color independently for the phase plot from the magnitude plot?
In my question I opened I tried to colour the poles in a different colour from the zeroes in the pzplot, but using the Response-Object I can only change both at the same time, not individually. If I use the "findobj" I do see the two scatter-plots for the zeroes and the poles, but any change to the properties do not seem to have any effect.
Andrew Ouellette
Andrew Ouellette 2025 年 1 月 27 日 20:51
Hi Jan,
I'll resond to your other question in that thread.
Starting in 24b, we introduced response objects in Control System Toolbox charts (as well as new charts objects). These response objects serve to unify the graphics across all axes in a Control System Toolbox chart for a single model.
There is no way to have the magnitude and phase portions of a single response display different colors using the new API. These graphics are generated from the same underlying dataset, so we chose to emphasize the fact that they are connected in this manner. Allowing for multiple colors would really complicate/confuse things such as legends, epecially for MIMO models where the same response could then have dozens of colors.

サインインしてコメントする。


Marcelo Moraes
Marcelo Moraes 2023 年 4 月 17 日
fig = gcf;
obj = findobj(fig,'Type','hggroup');
for idx = 1:numel(obj)
for jdx = 1:numel(obj(idx).Children)
obj(idx).Children(jdx).LineWidth = 2;
end
end

カテゴリ

Help Center および File ExchangePlot Customization についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by