Importing values from excel
조회 수: 8 (최근 30일)
이전 댓글 표시
Hi everyone, I'm trying to import datas from Excel to Matlab by using xlsread. my problem is that, it doesn't bring all of the values to command window but I can see the values in Workspace.It says NaN for cells such as 'DFX' or '78669-87'. I can't use import data all the time because the excel file needs to be updated everyday. So what I need is a code which can bring every values in each update to MaTLAB Is there another way to bring the datas? or any recommendation? Thank you:)
답변 (1개)
dpb
2018년 8월 6일
"...It says NaN for cells such as 'DFX' or '78669-87'."
As rightfully it should for numeric values; those aren't numbers but text in those cells.
If your data file format isn't regular you have to have some way to know which data are in which rows/columns to be able to interpret it correctly; xlsread will bring back every cell in the third (optional) output and you can parse it from there...
[n,t,r]=xlsread(...
n is the data which could be read as numeric, t is the text and r is the "raw" content of all cells of whatever type as a cell array from which one can tell exactly where any given piece of information is(*) for parsing the content programmatically.
It's much simpler if you can regularize the spreadsheet itself first.
(*) I think mayhaps behavior is different than was but will need to verify for your version in that the size of the n and r arrays originally was NOT the same as for r so that finding the location of a field label in r didn't actually correlate to where in n it's associated values actually were. I believe that has been fixed, but as noted you'll need to verify behavior to be sure.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Spreadsheets에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!