How to combine string and numbers before using xlswrite to export data into an Excel file?

조회 수: 1 (최근 30일)
I have like to write the below information into one Excel spreadsheet:
Cruise # Longitude Latitude Year Month Day
SE_01 -126 35 2017 9 17
SE_01 -123 31 2017 9 18
SE_01 -121 27 2017 9 20
How do I form the matrix? For Column 1, if it is numerical, I would do: A*size(3,1); but how about strings? Once I get the string column for Column 1, how do I combine it with the other numerical matrix values?
Many thanks!
  댓글 수: 2
Akira Agata
Akira Agata 2019년 3월 18일
I would recommend using table variable to store your data, and writetable function to save it as an Excel file. Please refer to the following documentation pages.
Leon
Leon 2019년 3월 18일
Many thanks for the reply! I really appreciate it.

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

채택된 답변

KSSV
KSSV 2019년 3월 18일
cruise = {'SE_01', 'SE_01','SE_01'}' ;
Longitude = [-126 -123 -121]' ;
Latitude = [35 31 27]' ;
Year = [2017 2017 2017]' ;
Month = [9 9 9 ]';
Day = [17 18 20]' ;
thedates = datetime(Year,Month,Day) ;
T = table(cruise,thedates,Longitude,Latitude);
writetable(T,'test.xlsx')
  댓글 수: 3

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

추가 답변 (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