数据存取格式
filename1 = 'g.txt';
fid1 = fopen(filename1,'w');
for i = 1 : length(g)for j=1:size(g,2)if(j==1)fprintf(fid1,'{%.16f,',g(i,j)); elseif(j>1&&j<151)fprintf(fid1,'%.16f,',g(i,j)); elsefprintf(fid1,'%.16f},\n',g(i,j));endend%fprintf(fid1,'\n');
end
fclose(fid1);
得到:
添加换行、中括号
天工C语言3×3赋值
#include <stdio.h>int main() {int array[3][3] = {{1, 2, 3},{4, 5, 6},{7, 8, 9}};// 打印数组内容以验证赋值for (int i = 0; i < 3; i++) {for (int j = 0; j < 3; j++) {printf("%d ", array[i][j]);}printf("\n");}return 0;
}