How to plot vertical line from X Axis to values on graph?

6 views (last 30 days)
Hi,
Ive got a fft plot with values linked by a line however, I would like the values to be plotted as a straight vertical line down to the x axis so that it just shows each frequency. I havent been able to find a possible way of doing this anywhere. Help on how to do this is very much appreciated.

Accepted Answer

Star Strider
Star Strider on 28 Dec 2019
The easiest way to do this is to use the stem function.
Example —
f = 0:0.05:pi; % Create Frequency Vector
A = rand(size(f)); % Create Fourier Transform Amplitude Vector
figure
plot(f, A, '-b')
hold on
stem(f, A, '-r', 'Marker','none') % Plot ‘stem’ Without Markers
hold off
grid
This plots the Fourier transform amplitudes with a blue line, and with red stem lines. Change the various properties to get the result you want.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!