フィルターのクリア

How to display the Amplitude and Phase Spectra plots in one page one on top of another?

1 回表示 (過去 30 日間)
Saptarshi Maji
Saptarshi Maji 2020 年 11 月 3 日
コメント済み: dpb 2020 年 11 月 3 日
I want to display the Amplitude and Phase Spectra plots in one page one on top of another, so if anyone could help me with that it would be great. Actually I am new to matlab, and I made this program by learning short programs published here on mathworks site.
%PLOTTING THE WAVE SPECTRUM OF THE DATA PROVIDED
%Taken :- The sample rate of 5 samples/second or deltaT = 0.2
data = importdata('Signal.txt');
a = (data);
dataT = importdata('Time.txt');
b = (dataT);
figure, plot(b,a,'b.-', 'LineWidth', 2);
axis([0 92.4 -2 2]);
grid on;
title('Wave Spectrum of Data', 'FontSize', 17);
xlabel('Time', 'FontSize', 13);
ylabel('Wavelet', 'FontSize', 13);
line([0,100], [0, 0], 'Color', 'k', 'LineWidth', 2);
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0 0 1 1]);
set(gcf, 'Name', 'Wave Spectrum Of Data', 'NumberTitle', 'Off');
hold on
%PLOTTING THE FFT(FAST FOURIER TRANSFORM) OF THE DATA
spectrum = fft(data);
deltaT = 0.2;
numElements = length(spectrum);
Fs = 1 / deltaT;
shiftedSpectrum = fftshift(abs(spectrum));
f = (Fs) * linspace(-numElements/2, numElements/2, numElements);
figure, plot(f, shiftedSpectrum, 'b.-', 'LineWidth', 2);
axis([0 1157.5 0 80]);
grid on;
title('FFT(FAST FOURIER TRANSFORM) of Wave', 'FontSize', 17);
xlabel('Frequency', 'FontSize', 13);
ylabel('Amplitude', 'FontSize', 13);
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0 0 1 1]);
set(gcf, 'Name', 'FFT Of Wave', 'NumberTitle', 'Off');
hold on
%PLOTTING THE AMPLITUDE SPECTRA OF THE DATA PROVIDED
nexttile([1 1]);
figure, plot(f, abs(spectrum), 'b.-', 'LineWidth', 2);
axis([0 1157.5 0 80]);
grid on;
title('Amplitude Spectrum of Data', 'FontSize', 17);
xlabel('Frequency', 'FontSize', 13);
ylabel('Amplitude', 'FontSize', 13);
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0 0 1 1]);
set(gcf, 'Name', 'Amplitude Spectrum', 'NumberTitle', 'Off');
hold on
%PLOTTING PHASE SPECTRA OF THE DATA PROVIDED
nexttile([1 2]);
figure, plot(f, angle(spectrum),'b.-', 'LineWidth', 2);
axis([0 1157.5 -4 4]);
grid on;
title('Phase Spectrum of Data', 'FontSize', 17);
xlabel('Frequency', 'FontSize', 13);
ylabel('Phase (radians)', 'FontSize', 13);
line([0,1157.5], [0, 0], 'Color', 'k', 'LineWidth', 2)
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0 0 1 1]);
set(gcf, 'Name', 'Phase Spectrum', 'NumberTitle', 'Off');
hold on
  1 件のコメント
dpb
dpb 2020 年 11 月 3 日
Remove the figure command from places where you expect subsequent plot on same axis.

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeGrid Lines, Tick Values, and Labels についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by