Develop a cleaner stem plot (Magnitude Spectra)
Show older comments
Hello,
My magnitude spectra of an unfiltered and filter ERP is showing multiple (and possibly unnecessary) plots on the left and right side of their stem plots, like so:


How can I make these plot look "cleaner" attached is a text file with data related to these plots.
ync = [.25 .5 .25]; %yn coefficients
ync1 = [-.085 .342 .485 .342 -.085]; %yn1 coefficients
ync2 = [-21/231 14/231 39/231 54/231 59/231 54/231 39/231 14/231 -21/231] %yn2 coefficients
Fs1 = 500; %Sampling Frequency
Ts1 = 1/Fs1; %Sampling Time
t1 = 0:1/Fs1:1-1/Fs1;
erp = load("data.txt");
erpMean = mean(erp, 2);
%Setting up for stem() [Unfiltered]
N = length(erpMean);
X = fft(erpMean);
X=1/N*abs(X);
X=[X(1) 2*X(2:end)']; %Converting column to row
f=0:Fs1/N:Fs1-Fs1/N;
%Setting up for stem() [Filtered]
z = filter(ync2,1,erpMean);
N1 = length(z);
X1 = fft(z);
X1 = 1/N1*abs(X1);
X1 = [X1(1) 2*X1(2:end)'] %Converting column to row
f1 = 0:Fs1/N1:Fs1-Fs1/N1;
figure(13)
plot(t1,erpMean);
title("Unfiltered ERP");
ylabel("Amplitude (mV)")
xlabel("Time(s)");
figure(14)
plot(t1,z);
title("Filtered ERP with Least-Square Polynomial Impulse")
ylabel("Amplitude (mV)");
xlabel("Time(s)");
%Magnitude Spectra
figure(15)
stem(f,X,'LineWidth',2);
grid on;
title("Unfiltered");
xlabel("Frequency (Hz)")
figure(16)
stem(f1,X1,'LineWidth',2);
grid on
title("Filtered")
xlabel("Frequency (Hz)")
Accepted Answer
More Answers (0)
Categories
Find more on Fourier Analysis and Filtering in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!