read xlsx file with headers and mixed double and character data into a matlab table inside a matlab program

조회 수: 37 (최근 30일)
I cannot find a way to read in the data with headers and all data types into memory. Clearly it can be done: I can click a few buttons at the top and do it. However, I want to do it in a program.
xlsread seems to be associated with matrices and readtable seems to be associated with tables. However, the document on how to do what I want doesn't seem to be in the readtable documentation.
Thanks in advance for any help. A suggestion: why can't matlab include the commands it executes to perform "clicks" in the command window? This would answer my question immediately. After all, it is straightforward to import this data using the import buttons at the top.
  댓글 수: 1
Peter Perkins
Peter Perkins 2017년 3월 3일
Richard, can you be more specific about what's not working with readtable? (Also, readtable has had behaviors added over the years, so it would be good to say what version of MATLAB you're using.)

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

답변 (1개)

Sid Jhaveri
Sid Jhaveri 2017년 3월 3일
Hi Richard,
1) You can use the Import Tool to also generate MATLAB scripts and functions. You can then use/modify it to use the same/similar functionality programmatically.
2) You can also achieve this by using " readtable " function. While using " readtable " function, you will have to specify that you would like to get the header and the type of data each column contains. For example,
readtable('test.xls','Format','%s%s%u%f%f%s','ReadVariableNames',true);

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by