On the workspace the following cfit
variables are obtained. I could not extract any data from such variables and was wondering if there is a code I am missing that could do this for me.
A =
General model:
fitresult(x) = y0+a*exp(-.5*((x-xa)/wa)^2)+b*exp(-.5*((x-xb)/wb)^2)+c*exp(-
.5*((x-xc)/wc)^2)+d*exp(-.5*((x-xd)/wd)^2)
Coefficients (with 95% confidence bounds):
a = 1693 (1089, 2297)
b = 8768 (8145, 9392)
c = 4480 (1942, 7017)
d = 3841 (2625, 5057)
wa = 39.36 (31.01, 47.7)
wb = 16.67 (15.92, 17.41)
wc = 13.05 (10.58, 15.51)
wd = 21.34 (15.41, 27.28)
xa = 99.23 (96.06, 102.4)
xb = 103.5 (103.1, 103.9)
xc = 273.5 (271.9, 275.2)
xd = 298.2 (285.9, 310.5)
y0 = 4158 (4049, 4266)
B =
General model:
fitresult(x) = y0+a*exp(-.5*((x-xa)/wa)^2)+b*exp(-.5*((x-xb)/wb)^2)+c*exp(-
.5*((x-xc)/wc)^2)+d*exp(-.5*((x-xd)/wd)^2)
Coefficients (with 95% confidence bounds):
a = 1693 (1089, 2297)
b = 8768 (8145, 9392)
c = 4480 (1942, 7017)
d = 3841 (2625, 5057)
wa = 39.36 (31.01, 47.7)
wb = 16.67 (15.92, 17.41)
wc = 13.05 (10.58, 15.51)
wd = 21.34 (15.41, 27.28)
xa = 99.23 (96.06, 102.4)
xb = 103.5 (103.1, 103.9)
xc = 273.5 (271.9, 275.2)
xd = 298.2 (285.9, 310.5)
y0 = 4158 (4049, 4266)
C =
General model:
fitresult(x) = y0+a*exp(-.5*((x-xa)/wa)^2)+b*exp(-.5*((x-xb)/wb)^2)+c*exp(-
.5*((x-xc)/wc)^2)+d*exp(-.5*((x-xd)/wd)^2)
Coefficients (with 95% confidence bounds):
a = 1693 (1089, 2297)
b = 8768 (8145, 9392)
c = 4480 (1942, 7017)
d = 3841 (2625, 5057)
wa = 39.36 (31.01, 47.7)
wb = 16.67 (15.92, 17.41)
wc = 13.05 (10.58, 15.51)
wd = 21.34 (15.41, 27.28)
xa = 99.23 (96.06, 102.4)
xb = 103.5 (103.1, 103.9)
xc = 273.5 (271.9, 275.2)
xd = 298.2 (285.9, 310.5)
y0 = 4158 (4049, 4266)
I would like to modify the above variable to produce the following table and save this table as a .txt or a .csv file:
Variables a b c d wa wb wc wd xa xb xc xd y0
A
B
C
Or
Variables = [a, b, c, d, wa, wb, wc, wd, xa, xb, xc, xd, y0]
A = [#, #, #, #, #, #, #, #, #, #, #, #, #]
B = [#, #, #, #, #, #, #, #, #, #, #, #, #]
C = [#, #, #, #, #, #, #, #, #, #, #, #, #]
You can create a table and print to a .txt file using the fprintf or writetable functions. Basically, you create a cell array containing the names of your variables as strings. Then you can pass these to a table in the writetable function, or simply print them in the fprintf function. You will also have to pass the variables to a vector, and you can create a loop which adds each variable from each fit to the vector. Here is a short example you can work off the principles of:
RowLabels = {'Variables';'A';'B';'C'};
a = [1693;1693;1693];
b = [8767;8767;8767];
c = [4480;4480;4480];
d = [3841;3841;3841];
T = table(a,b,c,d,'RowNames',RowLabels)
writetable(T,'myFile.txt','WriteRowNames',true)
You can view the file using the type command:
type myFile.txt
Obviously you'll have to create a loop of some sort which stores the variables values in the vectors a, b, c, d, etc. But hopefully this should give you an idea of what you need to do. You can explore the fprintf option, which works similarly. The syntax you can find by typing
doc fprintf
in the Command Window.