my graph looks weird

5 visualizaciones (últimos 30 días)
Sachini Perera
Sachini Perera el 16 de Abr. de 2021
Comentada: Sachini Perera el 16 de Abr. de 2021
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)');

Respuesta aceptada

Jan
Jan el 16 de Abr. de 2021
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 comentario
Sachini Perera
Sachini Perera el 16 de Abr. de 2021
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.

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Productos


Versión

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by