How can I set linewidth directly in bode command?
358 views (last 30 days)
Show older comments
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
Answers (4)
Birdman
on 25 Mar 2020
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;
Siddharth Jawahar
on 19 Jun 2024
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 Comments
Andrew Ouellette
on 28 Nov 2024 at 3:32
Note: Sid's answer is only applicable for releases prior to R2024b. Follow my answer starting in release R2024b.
Julius Bergmann
on 28 Nov 2024 at 14:18
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
on 28 Nov 2024 at 3:30
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;
0 Comments
Marcelo Moraes
on 17 Apr 2023
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
See Also
Categories
Find more on Response Computation and Visualization in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!