Fitting exponential

Hi, I want to fit my data with an exponential curve. I use fit and fittype=exp. So far no problem. But now I only want to use the first 600 data points and the last 200 datapoints (every trace has 15000 datapoints) and make an exponential fit over the whole trace only using this datapoints.
Can anybody help me which methods to use?
Thanks for your efforts!

2 Kommentare

Rick Rosson
Rick Rosson am 4 Aug. 2011
Are you asking for help with which methods to use for curve fitting, or are you asking for help in how to segregate the data in MATLAB into two separate sets of data?
fcarl
fcarl am 4 Aug. 2011
for curve fitting method only using the first and last datapoints but giving a exponential curve over the whole datapoints only using this first and last datapoints.

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

Rick Rosson
Rick Rosson am 4 Aug. 2011

3 Stimmen

I will assume that you have the 15,000 data samples stored in the MATLAB Workspace as a 15,000 x 1 column vector called dataset.x.
%%Create time domain:
N = size(dataset.x,1);
Fs = 125;
dt = 1/Fs;
dataset.t = dt*(0:N-1)';
%%Create subset:
p = 600;
q = 200;
subset.x = [ dataset.x(1:p) ; dataset.x(end-q+1:end) ];
subset.t = [ dataset.t(1:p) ; dataset.t(end-q+1:end) ];
%%Exponential fit:
fitType = 'exp1';
myFit = fit(subset.t,subset.x,fitType);
HTH.
Rick

3 Kommentare

fcarl
fcarl am 4 Aug. 2011
Thanks very much! Works well! :)
Rick Rosson
Rick Rosson am 4 Aug. 2011
Glad to have helped!
Rick
the cyclist
the cyclist am 4 Aug. 2011
Not that I'm bitter or anything, but ... uh ... isn't this exactly what I proposed in my answer? (Except that you did the work for him?)

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (3)

the cyclist
the cyclist am 4 Aug. 2011

0 Stimmen

If "x" is your explanatory variable, then it should be as simple as using x([1:600,end-199:end]), do similar for your response variable,and run fit() just as you did with "no problem" before. Or is it more complicated than that?
fcarl
fcarl am 4 Aug. 2011

0 Stimmen

But I also want the "timepoints" between this two "epochs" to be fitted. So that an exponential function goes from timepoint 0 to timepoint 15000 only using the first values and the last values.
Thanks for your answer!

5 Kommentare

the cyclist
the cyclist am 4 Aug. 2011
I'm confused. Sounds like you have a bunch of (t,x) pairs. You want to fit an exponential to the entire range of t, using data from only the small-t region and the large-t region. Without using the data from the middle-t region, I don't see how they can inform the fit. I'm guessing I'm misunderstanding something. Maybe you could post some code, or a figure, that gives more detail about what you are trying to do.
[Also, your note would be better placed as a comment on my answer, rather than as a separate answer.]
Yoav Livneh
Yoav Livneh am 4 Aug. 2011
Maybe you could do the cyclist's suggestion and then use interp1 to interpolate the middle section.
fcarl
fcarl am 4 Aug. 2011
The problem is a so called baselinedrift in my data. And I want to handle this problem by calculating a baseline. Because there are a lot of signals in the middle of the data I only want to use the beginning and the end and use this values to fit an exponential baseline over the whole data.
Rick Rosson
Rick Rosson am 4 Aug. 2011
Also, what is your time scale? You have 15000 points, but I assume that the time increment is not actually 1, but something much smaller. Do you know the sampling rate Fs and/or the time increment dt = 1/Fs?
fcarl
fcarl am 4 Aug. 2011
8ms (125 Hz)

Melden Sie sich an, um zu kommentieren.

fcarl
fcarl am 4 Aug. 2011

0 Stimmen

I want to give another explanation because I think it is a bit confusing: I have a data trace containing of 15.000 timepoints (every 0.008 s one frame -->125 Hz). At the beginning and the end of the trace there are no "events" so only baseline with noise. I want to fit the whole trace with an exponential function only using the first n data points and the last m datapoints. So that the points between do not play any role but the exponential function should consider the gap between because there I also need the baseline!

Community Treasure Hunt

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

Start Hunting!

Translated by