Dynamically adding to an excel sheet

6 ビュー (過去 30 日間)
Ryan Chhiba
Ryan Chhiba 2021 年 4 月 5 日
回答済み: Allen 2021 年 5 月 26 日
I have some EMG data that I processed and I want to export it into an Excel file. Because I am running a loop to process through multiple trials I wanted to export them all to the same spreadsheet, adding to the columns. With what I am currently using it exports each trial as a new row, but I need the data to all be exported into the same rows. Is there a way to do this?
for x= 1:12
Name=(char(all_files(data_files_index(x))));
newfilename= erase(Name, '_Feb_27_2021_conditionedEMG.mat');
newname= erase(newfilename, 'Subject 5_VTAS');
JASA.filename = newfilename;
JASA.SCM_L_EA = muscle_SCM_L_EA; % SCM_L_EA_CC_JTTT_T1
JASA.SCM_R_EA= muscle_SCM_R_EA;
JASA.UNE_L_EA = muscle_UNE_L_EA;
JASA.UNE_R_EA= muscle_UNE_R_EA;
JASA.UTR_L_EA_ = muscle_UTR_L_EA;
JASA.UTR_R_EA= muscle_UTR_R_EA;
JASA.SCM_L_MDF_ = muscle_SCM_L_MDF;
JASA.SCM_R_MDF1 = muscle_SCM_R_MDF;
JASA.UNE_L_MDF = muscle_UNE_L_MDF;
JASA.UNE_R_MDF_CA = muscle_UNE_R_MDF;
JASA.UTR_L_MDF = muscle_UTR_L_MDF;
JASA.UTR_R_MDF = muscle_UTR_R_MDF;
% These variables change with each trial
T = struct2table(JASA);
writetable(T, 'SO5 Data.xlsx', "WriteMode", "append")

回答 (1 件)

Allen
Allen 2021 年 5 月 26 日
It looks like your issue using the append feature has to do with your data being a table. Try using writematrix with your data as a numerical array instead. Note this will not include your table variable names as headers, but should be achieveable by adding write step before you begin adding your data.

カテゴリ

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