필터 지우기
필터 지우기

my graph looks weird

조회 수: 5 (최근 30일)
Sachini Perera
Sachini Perera 2021년 4월 16일
댓글: Sachini Perera 2021년 4월 16일
Hi,
My code is below and the answer i got also is below. But it looks weird with a lot of areas shaded. I want to remove the shaded part and make it so that only the lines are shown. How do i do this ?
fs = 200;
ts = 1/fs;
t = 0:ts:5;
z2 = 8*cos(30*pi*t+pi/3)+6*sin(50*pi*t-pi/3)+8*cos(70*pi*t-pi/4);
Y = fft(z2);
L = length(Y);
P2 = Y/L;
P1 = P2(1:L/2+1);
P1(2:end-1) = 2*P1(2:end-1);
f = fs*(0:(L/2))/L;
figure;
subplot(221)
stem(f,abs(P1),'linewidth',0.5);grid on; xlim([-40 40]);
title('Single-Sided Amplitude Spectrum of z_2(t)')
xlabel('f (Hz)');ylabel('|P1(f)|');
subplot(222)
stem(f,angle(P1)*57.3,'linewidth',0.5);grid on; xlim([-40 40]);
title('Single-Sided Phase Spectrum of z_2(t)')
xlabel('f (Hz)');ylabel('Degrees');
N = nextpow2(length(z2));
X = fftshift(fft(z2,2^N));
X = 2* X / length(z2);
k = -(length(X)-1)/2:1:length(X)/2;
f = k/length(X) * fs;
subplot(223);
stem(f,abs(X),'linewidth',0.5);grid;
xlabel('Frequency in Hz');
ylabel('Amplitude');xlim([-40 40]);
title('Double sided Magnitude spectrum of z_2(t)');
subplot(224);
stem(f,angle(X)*57.3,'linewidth',0.5);grid;
xlabel('Frequency in Hz');
ylabel('Amplitude');xlim([-40 40]);
title('Double sided Phase spectrum of z_2(t)');

채택된 답변

Jan
Jan 2021년 4월 16일
Maybe you want to remove the markers?
stem(f,angle(X)*57.3,'linewidth',0.5, 'Marker', 'none');
If you want something else, explain, what "only the lines are shown" means.
  댓글 수: 1
Sachini Perera
Sachini Perera 2021년 4월 16일
sorry for the poor explanation. When i meant only lines i only wants to show the important frequency components. For example, in the first subplot i only wants to show the 3 points that is has a higher amplitude than others.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Spectral Measurements에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by