Dynamically adding to an excel sheet
이전 댓글 표시
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
2021년 5월 26일
0 개 추천
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.
카테고리
도움말 센터 및 File Exchange에서 Spreadsheets에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!