当前位置: 代码迷 >> 综合 >> C语言中将数据写入文件中、matlab读取text中的文件
  详细解决方案

C语言中将数据写入文件中、matlab读取text中的文件

热度:78   发布时间:2024-02-10 05:22:39.0

方法如下,记录一下:

       FILE* fp = fopen("文件名.txt", "a+");/*文件名字定义,自动生成到本文件运行的目录*/if (fp == NULL){mexPrintf("file cannot open\n");}else{fprintf(fp, "%d %d \n", total_int_mag, pace_peaks);}fclose(fp);

matlab使用文件选择框读取要处理的文件

function DealWithData()
[filename, pathname] = uigetfile('*.*', '选择数据文件','MultiSelect', 'on'); %选择文件
if isequal(filename,0) ; return;end
fileName = fullfile(pathname, filename);
data_struct = importdata(fileName);
sensor_samples = data_struct.data;
x=sensor_samples(:,3); % 读取第三列
y=sensor_samples(:,4); % 读取第四列
plot(x, y);
end

 

  相关解决方案