How to connect minimum points into a line?
2 views (last 30 days)
Show older comments
How could I connect all minimums on x-ray spectrum into a one straight line? I'm attaching an exemplary spectrum file.
0 Comments
Accepted Answer
John D'Errico
on 27 Jan 2018
Edited: John D'Errico
on 27 Jan 2018
n = length(x);
M = [x,ones(n,1)];
C = lsqlin(M,y,M,y);
C =
-20.501
1191.8
plot(x,y,'b.',x,C(2) + C(1)*x,'r-')
grid on
If you actually meant something different, like how do you find ALL the local minima, then connect them with straight lines, then you need to use tools like findpeaks, then just call plot.
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!