Re: how can I alter the x-data of a cfit object after fitting?



Hi Matthew,

The CFIT object doesn't hold the x-data, so, unfortunately,
there is no hope of you scaling that.

I suspect the problem with fitting the Gaussian curve to the
scaled data is due to the start points (initial guess) of
the coefficients. CFTOOL will have worked out a good
starting point for the original data, but these probably
aren't so good for your scaled data.

In the generated m-file, look for some lines like

st_ = [9 22 4.0191415934240649 ];
set(fo_,'Startpoint',st_);

(where the particular numbers you have will depend on your
data). These three numbers correspond to the coefficients
a1, b1, c1, in

cf =
General model Gauss1:
cf(x) = a1*exp(-((x-b1)/c1)^2)
Coefficients (with 95% confidence bounds):
a1 = 8.45 (7.285, 9.615)
b1 = 0.1446 (0.1372, 0.152)
c1 = 0.06585 (0.05534, 0.07635)

From the formula " a1*exp(-((x-b1)/c1)^2)" we see that "b1"
and "c1" are on the same scale as x. Therefore if we scale
the x-data by k then we need to scale the estimates of these
two coefficients by k also. The coefficient "a1" is on the
same scale as y and so shouldn't need any attention in your
case. All going well, scaling these starting values should
improve the quality of the fit.

Cheers,
--Jon.


"Matthew McMahon" <matthew.mcmahon.nospam@xxxxxxxx> wrote in
message <f99sui$7jb$1@xxxxxxxxxxxxxxxxxx>...
Hi MATLAB gurus,

I am fitting histogram data with a Gaussian, using an M-file
I generated from the cftool and have since modified. The
data is derived from an image, and when I plot the histogram
and the fit together I want the independent (x-) axis units
to be calibrated to a physical distance, not just the
distance in pixels. The trouble is that if I do the
calibration first and then feed the data to the fitting
function, the fit messes up (probably because the
calibration factor is << 1).

What I would like to do is to do the fit with the
uncalibrated data (this works fine), and then simply scale
the x-axis points by the calibration factor (for plotting
purposes), without altering the y-axis data. I haven't
found a way to scale the x-axis yet; I've searched the help
for fit, cfit, fittype, fitoptions, and plot(curve fitting
toolbox version) to no avail.

The short form of the question is: How do I access the
x-data of a 'cfit' object after I've done the fit? Is that
possible?

Or, maybe, is there a workaround with the plot function that
will leave the data unchanged but automatically relabel the
ticks?

I'd be happy to share code snippets if it will help.

Thanks,
Matthew



.



Relevant Pages

  • how can I alter the x-data of a cfit object after fitting?
    ... I am fitting histogram data with a Gaussian, ... and the fit together I want the independent axis units ... calibration first and then feed the data to the fitting ...
    (comp.soft-sys.matlab)
  • Re: Update Query; But keep rest of field...
    ... Left$ and Right$ act like a scissors, counting from left or right, and cutting the string at that point, returning just that portion of the string. ... Comparing "Fitting ABS" with Left$will tell you if the beginning matches the eleven characters in "Fitting ABS". ... Will take "Fit ABS", and add everything except the first eleven characters, of tblItem.to it. ... Using the Design View to create a query, ...
    (microsoft.public.access.queries)
  • Re: Update Query; But keep rest of field...
    ... Using the Design View to create a query, ... UPDATE tblItem SET tblItem.itemMfgItemNumber = "Fit ABS" ... The goal is to find all items that START with "Fitting ABS" and change them ... Fitting PVC Sch40 1" 90 ELL SxS ...
    (microsoft.public.access.queries)
  • Re: Singular matrix in Invert_RtR
    ... Singular matrix in Invert_RtR ... The problem is that Gnuplot's fit uses a procedure known as Marquard-Levenberg algorithm, ... There is an alternative fitting algorithm, Simplex by Nelson & Mead, which is much more stable and can also minimise Chi^2 or the median of residuals in those cases where minimising the sum of squares is statistically inappropriate. ... Unfortunately, Simplex can not directly calculate the standard deviations for the parameters, that is probably the reason why many scientific fitting programs do not use it. ...
    (comp.graphics.apps.gnuplot)
  • Re: Fitting Nonlinear Complex Data(How do you do this?)
    ... Matlab documentation provides a 'curve fitting guide' where ... "For fitting curves in a case involving complex data set, ... I saw the help on how to fit nonlinear parameters I did not ...
    (comp.soft-sys.matlab)