my graph looks weird
조회 수: 7 (최근 30일)
이전 댓글 표시
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)');
댓글 수: 0
채택된 답변
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.
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!