From: Till on
Hello,

I am new to matlab and I would like to know whether there is a way to use a finite differences calculation to fit a curve (least square) of experimental data. Unfortunately there is no analytical solution to my problem and adjusting parameters by hand is quite exhausting. I would be grateful for any help and information.

Till
From: Torsten Hennig on
> Hello,
>
> I am new to matlab and I would like to know whether
> there is a way to use a finite differences
> calculation to fit a curve (least square) of
> experimental data.

Could you explain in more detail what you mean by
'use finite differences calculation to fit a
curve' ?

> Unfortunately there is no
> analytical solution to my problem and adjusting
> parameters by hand is quite exhausting. I would be
> grateful for any help and information.
>
> Till

Best wishes
Torsten.
From: Till on
> Could you explain in more detail what you mean by
> 'use finite differences calculation to fit a
> curve' ?


Thank you for your answer Torsten and sorry for the lack of specifity.
We are using simple finite differences calculation to model diffusion in ceramic material because there is no analytical solution available. If there was a simple functional dependence I could use this function in a non-linear least square fit with results from diffusion experiments to obtain parameters like the diffusion coefficient. But what I need to do now is use this finite differences calculation to fit the experimental results. After the calculation basically end up with a two column matrix with position and concentration of the diffusing particle, which could be compared with the experimental data. I would like to programm a fitting procedure, which should then adjust the parameters in a way, so that it converges the fit with the experimental data. I was told there might be a chance that this would be a bit more straight forward with Matlab. So I wanted to check whether anybody
has experience with this.

Best wishes,
Till
From: Steven_Lord on


"Till " <till.froemling(a)tuwien.ac.at> wrote in message
news:i39fus$jgv$1(a)fred.mathworks.com...
>> Could you explain in more detail what you mean by
>> 'use finite differences calculation to fit a
>> curve' ?
>
>
> Thank you for your answer Torsten and sorry for the lack of specifity. We
> are using simple finite differences calculation to model diffusion in
> ceramic material because there is no analytical solution available. If
> there was a simple functional dependence I could use this function in a
> non-linear least square fit with results from diffusion experiments to
> obtain parameters like the diffusion coefficient. But what I need to do
> now is use this finite differences calculation to fit the experimental
> results. After the calculation basically end up with a two column matrix
> with position and concentration of the diffusing particle, which could be
> compared with the experimental data. I would like to programm a fitting
> procedure, which should then adjust the parameters in a way, so that it
> converges the fit with the experimental data. I was told there might be a
> chance that this would be a bit more straight forward with Matlab. So I
> wanted to check whether anybody has experience with this.

Various products include curve fitting functionality. For a (probably
incomplete) list, take a look at the Curve Fitting Guide on the support
website:

http://www.mathworks.com/support/tech-notes/1500/1508.html

[The hyperlinks in that document are not working at the moment; I've asked
our support staff to correct them.]

If you have access to Optimization Toolbox, the first function I'd try for
this type of application (since it's likely going to be a nonlinear fitting
problem) is the LSQCURVEFIT function.

--
Steve Lord
slord(a)mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

From: Torsten Hennig on
> > Could you explain in more detail what you mean by
> > 'use finite differences calculation to fit a
> > curve' ?
>
>
> Thank you for your answer Torsten and sorry for the
> lack of specifity.
> We are using simple finite differences calculation to
> model diffusion in ceramic material because there is
> no analytical solution available. If there was a
> simple functional dependence I could use this
> function in a non-linear least square fit with
> results from diffusion experiments to obtain
> parameters like the diffusion coefficient. But what I
> need to do now is use this finite differences
> calculation to fit the experimental results. After
> the calculation basically end up with a two column
> matrix with position and concentration of the
> diffusing particle, which could be compared with the
> experimental data. I would like to programm a fitting
> procedure, which should then adjust the parameters in
> a way, so that it converges the fit with the
> experimental data. I was told there might be a chance
> that this would be a bit more straight forward with
> Matlab. So I wanted to check whether anybody
> has experience with this.
>
> Best wishes,
> Till

You will have to couple an integrator which solves
the diffusion equation with a nonlinear least-squares
solver.
In each iteration step, the nonlinear least-squares
solver (e.g. LSQCURVEFIT) will supply a suggestion
for the unknown parameters
(e.g. the diffusion coefficient).
With this suggestion, you can call a PDE-integrator
(e.g. pdepe) to solve the diffusion equation to get
the corresponding concentrations at the times when you measured your experimental data.
Returning the array
f_i = c_simulated(t_i) - c_experimental(t_i) (i=1,...,n)
to the least-squares solver finishes the procedure.

Best wishes
Torsten.