my graph looks weird

6 次查看(过去 30 天)
Sachini Perera
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