329 views (last 30 days)
Show older comments
byungkeuk cho on 25 Mar 2020
-
-
Link
Direct link to this question
https://jmaab.mathworks.com/matlabcentral/answers/512797-how-can-i-set-linewidth-directly-in-bode-command
Answered: Siddharth Jawahar on 19 Jun 2024 at 1:46
Open in MATLAB Online
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?
0 Comments Show -2 older commentsHide -2 older comments
Show -2 older commentsHide -2 older comments
Sign in to comment.
Sign in to answer this question.
Answers (4)
Birdman on 25 Mar 2020
Open in MATLAB Online
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 Comment Show -1 older commentsHide -1 older comments
Show -1 older commentsHide -1 older comments
byungkeuk cho on 25 Mar 2020
Direct link to this comment
https://jmaab.mathworks.com/matlabcentral/answers/512797-how-can-i-set-linewidth-directly-in-bode-command#comment_815459
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.
Sign in to comment.
Star Strider on 25 Mar 2020
Open in MATLAB Online
It is possible to do this without getting the outputs from bode and doing separate plots, however it requires some fairly extensive ‘handle diving’:
sys = tf(4,[1 0.5 4]);
figure(1)
bode(sys)
grid
Fh = gcf; % Handle To Current Figure
Kids = Fh.Children; % Children
AxAll = findobj(Kids,'Type','Axes'); % Handles To Axes
Ax1 = AxAll(1); % First Set Of Axes
LinesAx1 = findobj(Ax1,'Type','Line'); % Handle To Lines
LinesAx1(2).LineWidth = 5; % Set ‘LineWidth’
Ax2 = AxAll(2); % Second Set Of Axes
LinesAx2 = findobj(Ax2,'Type','Line'); % Handle To Lines
LinesAx2(2).LineWidth = 5; % Set ‘LineWidth’
Experiment to get different results.
2 Comments Show NoneHide None
Show NoneHide None
byungkeuk cho on 25 Mar 2020
Direct link to this comment
https://jmaab.mathworks.com/matlabcentral/answers/512797-how-can-i-set-linewidth-directly-in-bode-command#comment_815458
Thank you for your answer.
It looks a bit complicated as you said.
Anyway, I will keep it as another option.
Star Strider on 26 Mar 2020
Direct link to this comment
https://jmaab.mathworks.com/matlabcentral/answers/512797-how-can-i-set-linewidth-directly-in-bode-command#comment_815478
My pleasure.
This is the only way I am aware of to change the linewidths (or any other options) in the Control System Toolbox and System Identification Toolbox graphics functions.
Sign in to comment.
Marcelo Moraes on 17 Apr 2023
Open in MATLAB Online
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
0 Comments Show -2 older commentsHide -2 older comments
Show -2 older commentsHide -2 older comments
Sign in to comment.
Siddharth Jawahar on 19 Jun 2024 at 1:46
Open in MATLAB Online
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
0 Comments Show -2 older commentsHide -2 older comments
Show -2 older commentsHide -2 older comments
Sign in to comment.
Sign in to answer this question.
See Also
Categories
Control SystemsControl System ToolboxGet Started with Control System Toolbox
Find more on Get Started with Control System Toolbox in Help Center and File Exchange
Tags
- bode plot line width
Products
- MATLAB
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- Deutsch
- English
- Français
- United Kingdom(English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)
Contact your local office