Help with fitting curve to data

1 view (last 30 days)
H. Donna Gust
H. Donna Gust on 15 Dec 2011
Hey all,
I'm new to matlab, and I have to make a smoothed curve to fit the peaks of my data, similar to this picture:
I've been trying to use findpeaks(), like in this example: http://www.mathworks.com/help/toolbox/signal/ref/findpeaks.html
But I can't produce the curve like in the picture, any good ideas?
Thanks!
Donna

Answers (4)

bym
bym on 15 Dec 2011
Maybe one of these enveloping tools could help:
however, most of the PSD envelopes I've seen are done manually, not by algorithm

H. Donna Gust
H. Donna Gust on 16 Dec 2011
I found that I could use specplot and take the 4th power of whatever spectrum and use that to fit nicely over, example:
so: semilogy(x,y); hold on; specplot(spectrum(x.^4,128),Fs);

H. Donna Gust
H. Donna Gust on 17 Dec 2011
Actually, does anyone know how I would go about collecting the actual data points of this operation? It may sound strange I guess, but I'd like to save the values of the line above the spectra data. I can't figure out how to simply get a point on that line with the corresponding frequency...any thoughts?
Donna

H. Donna Gust
H. Donna Gust on 18 Dec 2011
Figured this out eventually...
h=figure; semilogy(x,y); hold on; specplot(spectrum(x.^4,128),Fs);
ax=findall(h,'Type','line'); xx=get(ax,'XData'); yy=get(ax,'YData'); xxx=[xx{1,1}' yy{3,1}']; % the values {1,1} and {3,1} may vary for you, i found which ones i needed by opening the fig, then -> edit -> plot browser, and selecting the lines i needed, then to properties to see the values
semilogy(xx{1,1},yy{3,1}); %just to make sure it's the same line

Categories

Find more on Curve Fitting Toolbox 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!