plot multiple PSD lines in single graph
古いコメントを表示
Hi, i have two different PSD plot for two different file...but i am not able to plot these two in one graph ,because i want to compare both. here is a sample of my code...
signal = load('tremor_analysis.txt');
N = length(signal);
fs = 62.5; % 62.5 samples per second
fnyquist = fs/2; %Nyquist frequency
X_mags = abs(fft(signal));
bin_vals = [0 : N-1];
fax_Hz = bin_vals*fs/N;
N_2 = ceil(N/2);
semilogx(fax_Hz(1:N_2), 20*log10(X_mags(1:N_2)))
xlabel('Frequency (Hz)')
ylabel('Power (dB)');
title({'Single-sided Power spectrum' ... ' (Frequency in shown on a log scale)'});
axis tight
5 件のコメント
Mohammad Monfared
2014 年 4 月 15 日
Have you tried 'hold on' after first call to 'semilogx'?
md
2014 年 4 月 15 日
Mohammad Monfared
2014 年 4 月 15 日
try the 'plot' instead of 'semilogx' and then 'hold on'. At the end add this:
set(gca,'XScale','log')
For what definition of "not working"? That is NEVER a sufficient problem description.
There's no indication of a second plot in the posted code--either follow up the above with another data file and plot command after executing hold on or create the other dataset before plotting and plot both together by place them in the same call as columns in an array presuming you're using the same frequency binning for both.
md
2014 年 4 月 15 日
回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Spectral Measurements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!