在工作区中,获取以下cfit
变量。我无法从这些变量中提取任何数据,并想知道是否有一个我错过的代码可以为我做这个。
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)
我想修改上面的变量来生成下表并将此表保存为.txt或.csv文件:
Variables a b c d wa wb wc wd xa xb xc xd y0
A
B
C
或者
Variables = [a, b, c, d, wa, wb, wc, wd, xa, xb, xc, xd, y0]
A = [#, #, #, #, #, #, #, #, #, #, #, #, #]
B = [#, #, #, #, #, #, #, #, #, #, #, #, #]
C = [#, #, #, #, #, #, #, #, #, #, #, #, #]
答案 0 :(得分:1)
您可以使用fprintf或writableable函数创建表并打印到.txt文件。基本上,您创建一个包含变量名称的单元格数组作为字符串。然后,您可以将这些传递给可写函数中的表,或者只是在fprintf函数中打印它们。您还必须将变量传递给向量,并且可以创建一个循环,将每个拟合中的每个变量添加到向量。这是一个简短的例子,你可以解决以下原则:
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)
您可以使用type命令查看文件:
type myFile.txt
显然,您必须创建某种循环,将变量值存储在向量a,b,c,d等中。但希望这可以让您了解需要做什么。您可以浏览fprintf选项,它的工作方式类似。您可以通过键入
找到的语法doc fprintf
在命令窗口中。