필터 지우기
필터 지우기

How to export a cell matrix into a MS Excel file

조회 수: 6 (최근 30일)
Paul Barrette
Paul Barrette 2023년 12월 8일
댓글: Voss 2023년 12월 8일
Attached is a cell array which I would like to export into a MS Excel spreasheet where each row correspond to one (of 12) years and would represent a tab inside that Excel file. Each of the 8 columns (or variables) would represent a column inside each tab.
I know this can be done with the 'xlswrite' command (see here for an example). But that command has now been superseded by the 'writecell' command, which I have problems with. Thanks!
  댓글 수: 3
Dyuman Joshi
Dyuman Joshi 2023년 12월 8일
편집: Dyuman Joshi 2023년 12월 8일
What problems did you encounter with writecell?
And which array from the following list are you trying to save? ans?
z = load("THRESH_DATA.mat")
z = struct with fields:
DATA_ISI: {12×1 cell} DATE: [23060×1 datetime] DATES_ECCC: [12×4 double] DATE_ISI: [2868×1 datetime] DATE_RANGE_ECCC: [23×4 double] DATE_RANGE_ISI: [12×4 double] DAY: [23060×1 double] D_YEAR_ISI: {12×1 cell} ECCC_File: [23060×36 table] FDD_Fall: [12×1 double] FIRST_1_CB: [12×2 double] ISI_File: [2868×24 table] ISI_NUMBER: [2868×1 double] ISIdata_CBeauharnois: 1 ISIdata_LakeStLawrence: 0 MAX_TP: [23060×1 double] MEAN_TP: [23060×1 double] MIN_TP: [23060×1 double] MONTH: [23060×1 double] STARTYEAR: [2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011] THRESH_DATA: {12×8 cell} YEAR: [23060×1 double] a: [1×1 TiledChartLayout] ans: {[110×1 datetime] [110×1 double] [110×1 double] [110×1 double] [110×1 double] [110×1 double] [110×1 double] [110×1 double]} aver_CB_0to1: 51.5056 aver_CB_1to2: 96.9560 aver_CB_to0: 27.3914 aver_LSL_0to1: 80.5893 aver_LSL_1to2: 104.3250 aver_LSL_to0: 32.7929 ax: [1×1 Axes] bstfit2: [3.8500 -7.2983e+04] coeff_CB: [1.6133 -3.0864e+03] coeff_LSL: [3.1997 -6.1568e+03] dumISI: [12×1 double] end_day: 20-Mar-2012 end_day_ini: 20 end_day_isi: 20-Mar-2012 end_month: 3 firstISI: [12×1 double] idx_year: 12 init: 0 k: 10 m: 62 n: 12 no_days_AirTemp: 10 p_ISI: [1×1 struct] p_ISI_model: [1×12 Line] p_ISI_obs: [1×12 Line] sl_bst: 5 slope: 1.6133 slope_CB_0to1: -0.7768 slope_CB_1to2: -0.6994 slope_CB_to0: 0.9104 slope_LSL_0to1: -1.2459 slope_LSL_1to2: 1.1121 slope_LSL_to0: 0.4805 start_day: 01-Dec-2011 start_day_ISI: 1 start_day_isi: 01-Dec-2011 start_month_ISI: 12 start_year: 2000 temperature_DD: 0 temporary_DD: 18 thresh1: 10 thresh2: 20 y_intercept: -3.0864e+03 yearcount: 12
Paul Barrette
Paul Barrette 2023년 12월 8일
Thanks, @Dyuman Joshi. I had NO idea THRESH_DATA.mat contained so many variables! (I thought it was only 'THRESH_DATA', which is what I'm interested in). As for the problems in using 'writecell', it was mostly about sorting out the differences between [ vs { vs ( in the script. The Documentation is written for programming-savvy folks.

댓글을 달려면 로그인하십시오.

채택된 답변

Voss
Voss 2023년 12월 8일
filename = 'test_THRESH_DATA.xlsx';
N = size(THRESH_DATA,1);
for ii = 1:N
T = table(THRESH_DATA{ii,:});
writetable(T,filename,'Sheet',ii,'WriteVariableNames',false);
end
  댓글 수: 3
Paul Barrette
Paul Barrette 2023년 12월 8일
이동: Dyuman Joshi 2023년 12월 8일
Thanks, @Voss. That's exactly what I was looking for.
Voss
Voss 2023년 12월 8일
You're welcome!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

제품


릴리스

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by