Trying to figure out a algorithm to filter out some data, since I dont have any additional toolbox.
Show older comments
Hi,
I have uploaded a mat file which contains two vectors e and v. e is for energy and v is for voltage, but thats not important. And I plot them like this.
plot(v,e);
grid on;
grid minor;
xlim([3.485,3.6]);
set(gca, 'XDir','reverse');

and when you plot the values, you get this plot with those spikes. I am trying to figure out how to remove those spikes, but i cant see any patterns. I dont have any toolbox, so i have to use matlab and my brain to figure this out. But i am currently struggling to come up with an idea. If anyone can help me, kindly please help me. Thank you.
Accepted Answer
More Answers (2)
load("eeandv.mat")
tol = 0.005;
idx = abs(diff(e)) <= tol;
e = e(idx);
v = v(idx);
plot(v,e)
grid on;
grid minor;
xlim([3.485,3.6]);
set(gca, 'XDir','reverse');
Alan Stevens
on 9 Oct 2025
Edited: Alan Stevens
on 9 Oct 2025
Here's one possibility, though it isn't a general solution, it just works for this data set
load('eeandv.mat')
xlo =3.485; xhi = 3.6;
ixlo = find(v==xlo); ixhi= find(v==xhi);
ylo = e(ixlo); yhi = e(ixhi);
x = [xlo, xhi];
y = @(x) ylo + (x-xlo)*(yhi-ylo)/(xhi-xlo);
e(e<y(v)) = NaN;
plot(v,e,'.');
grid on;
grid minor;
xlim([3.485,3.6]);
set(gca, 'XDir','reverse');
Categories
Find more on MATLAB 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!


