adding data to an existing excel file

1 回表示 (過去 30 日間)
Elaheh
Elaheh 2018 年 4 月 19 日
回答済み: Walter Roberson 2018 年 4 月 19 日

Hi,

I have the following script. I want to write the "data" from 36 folders to be written in one excel file, one at a time. For example, the first piece of data be written in columns A,B, and C. The second piece of data be written in columns D, E, and F, etc. How should I change the script? I thank you in advance.

       clc, clear, close all;
       STIMroot='C:\Users\';
       Drop=strcat('C:\Users\final.xls');
        for i=1:36
            for j=1:2               
                for h=1:29
                   STIMfile=strcat(STIMroot,num2str(i),'\',num2str(i),'_',num2str(j),'_',num2str(h),'.xls');
                    if exist(STIMfile,'file')
                    STIMdata = xlsread(STIMfile); 
                    data=STIMdata(:,3:5);
                    m=1;
                    [rows,cols] = size(data);
                    startingcolumn = (m-1)*cols + 1;
                    colsstring = num2str(startingcolumn);
                    m=m+1;
                    xlswrite(Drop,data,1,colsstring);
               end
          end                                    
    end
 end

回答 (1 件)

Walter Roberson
Walter Roberson 2018 年 4 月 19 日
Look in the File Exchange for xlsappend

カテゴリ

Help Center および File ExchangeSpreadsheets についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by