Cannot add line to magnitude graph after FFT
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I tried to use FFT to transfer a time domain data to frequency domain, and it appear two graphs (magnitude against frequency and phrase against frequency). I want to hide phrase graph and add a vertical line to the magnitude graph. However, the line only add to the phrase graph even I have hidden it. Could any talented matlab user advise how can I add the vertical line to the magnitude graph? Thank you!
T = 0.001
G3data1 = iddata(G3x1,[],T)
G3data2 = iddata(G3x2,[],T)
G3data3 = iddata(G3x3,[],T)
G3data4 = iddata(G3x4,[],T)
M3f1 = fft(G3data1)
M3f2 = fft(G3data2)
M3f3 = fft(G3data3)
M3f4 = fft(G3data4)
M3f = merge(M3f1, M3f2, M3f3, M3f4,N)
opt = dataPlotOptions('frequency');
opt.PhaseVisible = 'off';
opt.Xlim = [1 50];
opt.FreqUnits = 'Hz';
opt.FreqScale = 'linear';
plot(M3f,opt)
xline(5)
title('Frequency Graph')
legend({'data1','data2','data3','data4'})
0 Kommentare
Antworten (1)
Shivansh
am 8 Sep. 2024
Hi Sam,
You can add a vertical line to the magnitude graph while hiding the phase graph by adding the line to the correct axes.
You can refer to the following code snippet for reference:
% Plot the data with phase hidden
plot(M3f, opt);
% Get handles to the axes
ax = gca; % Get current axes, assuming it's the magnitude plot
% Add a vertical line to the magnitude plot
xline(ax, 5);
% Customize the plot
title(ax, 'Frequency Graph');
legend(ax, {'data1', 'data2', 'data3', 'data4'});
I hope this resolves the issue!
0 Kommentare
Siehe auch
Kategorien
Mehr zu Directed Graphs finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!