怎样用matlab从txt文件中读取数据,每次只读取一行?答:temdat=load('D:\test.txt');if temdat== -1 ('Error opening the file');end figure;h=plot3(temdat(:,1),temdat(:,2),temdat(:,3));set(h,'linestyle','none')hold on;grid on;[x,y]=meshgrid(linspace(-150,150,500),linspace(-150,150,500));z = griddata(temdat(:,...
在matlab,怎样读取一个txt文件每一行,带入公式,计算结果,输个入另一...答:假设读入数据文件为t1.txt,写入文件为t2.txt clc,clear;fid = fopen('t1.txt','r');A=fscanf(fid,'%d',[3 inf]);%d表示十进制整数 fclose(fid);A=sum(A,1);A=A';fid=fopen('t2.txt','w');fprintf(fid,'%d',A);fclose(fid);