Using xlsread values from column P and forward

2 ビュー (過去 30 日間)
Ricardo G
Ricardo G 2018 年 6 月 14 日
編集済み: Walter Roberson 2018 年 6 月 15 日
I am reading an excel file using xlsread() function.
xlRange = 'B2:AV2';
result = xlsread(filename, sheet, xlRange);
When I print the result matrix I noticed the xlsread() is not returning expected results. The first elements in the result matrix (from range B2 to O2) are equal to the values in the Excel file. However, and strangely, values from range P2 to AV2 does not coincide with the values in the Excel file.
So I proceeded to do the following test
result = xlsread(filename, sheet, 'P2');
And when I print the result matrix, its value its completely different from the value in the Excel file.
Digging a little bit more, I found out that the value returned for P2 was not a random number, but the same as for C2. And subsequently, value requested for Q2 returns the value in D2 and so on.
P2 = C2
Q2 = D2
R2 = E2
...
I have been scratching my head for hours, any help would be much appreciated

採用された回答

ES
ES 2018 年 6 月 14 日
編集済み: Walter Roberson 2018 年 6 月 15 日
What kind of data do you have in your excel file? xlsread can have three outputs, numbers, text and raw. Which of it are you using?
Becuase when you simply use
result = xlsread(filename, sheet, xlRange);
only the numbers in the range are read.
Use to read all contents
[num,txt,raw] = xlsread(___)
  1 件のコメント
Ricardo G
Ricardo G 2018 年 6 月 15 日
You were right, the some of the data was pasted/imported as text, had to convert the cell type to number and the problem was fixed! Thank you!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Import from MATLAB についてさらに検索

タグ

製品


リリース

R2016a

Community Treasure Hunt

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

Start Hunting!

Translated by