I want to export the data of a FindFit in a .txt-file to do some postprocessing.
My fit is:
fit6 = FindFit[data, {Subscript[model, JCA], 1 < \[Alpha] < 4,1*10^-5 < Subscript[\[Lambda], th] < 1*10^-3,1*10^-5 < Subscript[\[Lambda], vis] <1*10^-3}, {{Subscript[\[Lambda], vis], 1*10^-6}, {Subscript[\[Lambda], th],1*10^-6}, \[Alpha]}, f, MaxIterations -> 100000]
The blue curves are my experimental data and the red curve is the fitted function.
And now I want to export the calculated data (x,y-values) of the fitted red curve as a .txt-file. How do I get these values?
EDIT: I add my model and corresponding parameters and FindFit
some parameters:
T0 = 21;
P0 = 104500;
HR = 60;
kappla = 0.026;
T = T0 + 273.16;
Pr = 0.71;
R = 287.031;
Rvp = 461.521;
Pvp = 0.0658*T^3 - 53.7558*T^2 + 14703.8127*T - 1345485.0465;
\[Eta] = -5.95238*10^-11*T^2 + 2.71368*10^-14*T^3 +
7.72488*10^-8*T; (*Viskosität von Luft in [Pa/s]*)
Cp = 4168.8*(-6.46128*10^-11*T^3 + 1.69194*10^-7*T^2 -
7.55179*10^-5*T + 0.249679);
Cv = Cp - R;
\[Gamma] = Cp/Cv;
\[Rho]0 = P0/(R*T) - (1/((R - 1)*Rvp))*(HR/100)*(Pvp/T);
c0 = (\[Gamma]*P0/\[Rho]0)^0.5 ;
kair = \[Omega]/c0;
Z0 = \[Rho]0*c0;
\[Omega] := 2*Pi*f;
d = 24*10^-3;
\[Sigma] = 70000;
\[Phi] = 0.989;
model:
Reff = \[Rho]0 \[Alpha] (1 + ((\[Phi] \[Sigma]) Sqrt[
1 + (I (4 \[Omega] \[Rho]0 \[Eta] \[Alpha]^2))/(\[Sigma]^2 \
\[Phi]^2
\!\(\*SubsuperscriptBox[\(\[Lambda]\), \(vis\), \(2\)]\))])/(
I (\[Omega] \[Rho]0 \[Alpha])));
Keff = (P0 \[Gamma])/(\[Gamma] - (\[Gamma] - 1)/(
1 + (8 \[Eta] Sqrt[1 + (I (\[Omega] Pr \[Rho]0
\!\(\*SubsuperscriptBox[\(\[Lambda]\), \(th\), \(2\)]\)))/(
16 \[Eta])])/(I (\[Omega] Pr
\!\(\*SubsuperscriptBox[\(\[Lambda]\), \(th\), \(2\)]\) \[Rho]0))));
kw = \[Omega] Sqrt[Reff/Keff];
Zc = Sqrt[Reff Keff];
Zs = -((I Zc Cot[kw d])/Z0);
r = (Zs - 1)/(Zs + 1);
model = abs1 = 1 - Abs[r]^2;
Fit:
fit1 = FindFit[
data, {model, 1 < \[Alpha] < 4,
1*10^-5 < Subscript[\[Lambda], th] < 1*10^-3,
1*10^-5 < Subscript[\[Lambda], vis] <
1*10^-3}, {{Subscript[\[Lambda], vis],
1*10^-6}, {Subscript[\[Lambda], th], 1*10^-6}, \[Alpha]}, f,
MaxIterations -> 100000]
Show[Plot[
Labeled[Subscript[model, Daimler] /. fit1, "Daimler"], {f, 200,
8000}, PlotRange -> {{200, 7500}, {0, 1}}, PlotStyle -> Red],
ListPlot[Labeled[data, "import"],
PlotRange -> {{200, 7500}, {0, 1}}]]
Extraction of my data (x,y):
{00143.7500 0000.0793 00487.5000 0000.2002 00831.2500 0000.5153 01175.0000 0000.8803 01518.7500 0000.9933 01862.5000 0000.9361 02206.2500 0000.8575 02550.0000 0000.8051 02893.7500 0000.7677 03237.5000 0000.7691 03581.2500 0000.7717 03925.0000 0000.7945 04268.7500 0000.8263 04612.5000 0000.8464 04956.2500 0000.8688 05300.0000 0000.8810 05643.7500 0000.8906 05987.5000 0000.9019 06331.2500 0000.9152}
NonlinearModelFit[]
instead, so that getting the required data is convenient:nlm = NonlinearModelFit[data, model, parameters, x]; Export["filename.dat", Transpose[{data[[All, 1]], data[[All, 2]], nlm["PredictedResponse"], nlm["FitResiduals"]}], "Table"]
. $\endgroup$NonlinearModelFit[]
usesFindFit[]
internally, so it doesn't make sense that one works and the other does not. Did you remember to include constraints and starting values? Also, since you included neither your raw data nor your model in your question, I have no way of knowing whether you used it right. $\endgroup$