(* mathematica 文件输出并整理 单片机能用的格式 *)
fname = FileNameJoin[{"F:\\", "testfile.txt"}]
s = OpenWrite[fname]
tst = Table[x, {x, 1, 122}]; (* 测试数据 *)
tst = phif; (* 输入数据 *)
row = 11;
vertical = 11;
For[m = 0, m < vertical, m++;
WriteString[ s, "{"];
For[n = 1, n <= row, n++;
WriteString[ s, tst[[((m - 1)*11) + (n - 1)]], "," ] ;
]
WriteString[ s, "},\n"];
]
Close[s]
FilePrint[fname]
输出:例
{Indeterminate,Indeterminate,Indeterminate,Indeterminate,Indeterminate,Indeterminate,Indeterminate,Indeterminate,Indeterminate,Indeterminate,Indeterminate,},
{0.00997917,0.00990745,0.00984411,0.00977081,0.00973629,0.00948273,0.00908854,0.00851531,0.00828393,0.00804085,0.00788132,},
{0.0100938,0.010066,0.00996137,0.00987581,0.00974504,0.00955472,0.00934078,0.00911649,0.00860613,0.00818471,0.00763962,},
{0.00993056,0.0101807,0.0106068,0.011094,0.0115556,0.0120427,0.012535,0.0130198,0.013573,0.00879166,0.00810136,},
{0.00963542,0.0099405,0.0103453,0.0107624,0.0112045,0.0116211,0.0119887,0.0123624,0.0127299,0.0130629,0.0132596,},
{0.00934167,0.00965542,0.0100682,0.0104951,0.010959,0.0113858,0.0117752,0.0121477,0.0124761,0.012545,0.0126248,},
{0.0090625,0.00935128,0.00975033,0.0101947,0.0106663,0.0111338,0.0115723,0.0119755,0.0123377,0.0124138,0.0124741,},
{0.00871726,0.00900981,0.00942748,0.00987602,0.0103514,0.0108803,0.0113642,0.0118577,0.0120355,0.0118895,0.0116442,},
{0.00842188,0.00871496,0.00910048,0.00954254,0.0100556,0.0105861,0.0111222,0.0112336,0.0112543,0.0112158,0.0110998,},
{0.00811111,0.00840434,0.00879221,0.00925132,0.00977746,0.00997679,0.0101982,0.0104277,0.0106486,0.0108405,0.0109858,},
{0.007825,0.00798598,0.0082157,0.00850649,0.00884912,0.00923288,0.00964515,0.0100703,0.0104903,0.0108876,0.0109855,},