필터 지우기
필터 지우기

Export data from MATLAB table to new table in Excel

조회 수: 44 (최근 30일)
Rachael Courts
Rachael Courts 2020년 5월 25일
댓글: rubindan 2020년 6월 15일
See image below for reference.
I have created a 5763 x 15 table named 'data' which you can see in my workspace. I am wanting to export all information (including headers) from this table into xlsx.
I thought I'd try code on just 3 columns to see if I could get it working. For all the coding I have tried I receive 'T' as just 3 header columns without any information within the rows.
In the image you will see a few of the many attempts I have tried. Any help would be welcomed!

채택된 답변

rubindan
rubindan 2020년 5월 25일
To use writetable(T) the object T must be a table class object, created with the table command.
In your case T is a cell array of three strings. The correct form to use would be
id = some_vector_of_numbers;
UTS = anouther_vector;
startSeconds = yet_another_vector;
T = table(id,UTS,startSeconds);
writetable(T,'data.xlsx')
Matlab will use the column names id,UTS, and startSeconds for the header.
  댓글 수: 2
Rachael Courts
Rachael Courts 2020년 6월 11일
Hi Rubindan,
I've just tried your suggestion now. As a MATLAB novice I'm unsure what 'some_vector_of_numbers' is supposed to be. I tried this
Id = 5763
UTC = 5763
startSeconds = 5763
T = table(Id,UTC,startSeconds)
writetable(T,'data.xlsx')
The above just gave an output of T 1x3 where each column was the headers suggested above, not showing any data?
I also tried changing '5763' to '5763x15' but it didnt work, I'm getting these numbers from the table where I want the data to come from, see below.
rubindan
rubindan 2020년 6월 15일
I was thinking that id, startSeconds, and UTS are columns in your table, but now I see that your table has 15 columns. In thaty case I do not undesrant what they are.
To save the table as it is just type writetable(data,'data.xlsx')

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

추가 답변 (0개)

카테고리

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

제품

Community Treasure Hunt

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

Start Hunting!

Translated by