【问题标题】:Writing data to a single sheet of excel using MATLAB使用 MATLAB 将数据写入单张 excel
【发布时间】:2017-06-06 04:03:38
【问题描述】:

我正在处理两列文本文件,并希望将 Excel 文件中两列相减的结果保存在一张表中。我编写了以下代码,但下面的程序在单个工作簿中的单独工作表中编写差异,我需要在一张工作表中所有 50 个(差异)。请帮我。谢谢你。

close all;
for k = 1:9
filename = sprintf('Data_F_Ind000%d.txt',k);
data = load (filename);
f = data(:,1) - data (:,2);
xlswrite('difference_1_9.xlsx',f,1);
end

【问题讨论】:

    标签: excel matlab


    【解决方案1】:

    您可以将所有结果存储到矩阵中,然后写入 excel。检查下面的伪代码。

    N = 10 ; % your number of lines in data/ each file
    nfiles = 9 ;   % number of files
    iwant = zeros(N,nfiles) ;
    for i = 1:nfiles
        data = rand(N,2) ;
        iwant(:,i) = data(:,1)-data(:,2) ;
    end
    myfile = 'myfile.xlsx' ;
    
    xlswrite(myfile,iwant)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-09-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多