xlsread unable to import data or sorts the imported data. please advice.
古いコメントを表示
I am trying to read x and y coordinates into separate arrays, say x and y. Sometimes,
- xlsread does not read any value from the specified column
- xlsread grabs the value from the column but sorts them resulting in mismatch between x and y coordinates
I am not sure whats the way around? Is it a bug? It happens sometimes only.
1 件のコメント
Image Analyst
2015 年 4 月 17 日
編集済み: Image Analyst
2015 年 4 月 17 日
It could be a weird entry in your Excel cell. Who knows? Not us, because you didn't attach a workbook for which it fails for us to check.
採用された回答
その他の回答 (1 件)
Ken Atwell
2015 年 4 月 17 日
I can answer question #2, I think. If you have two separate variables and you sort one, then, yes, the two variables will now be out of sync. To can overcome this by:
- Use a container like a table that keeps columns of related data synched.
- Use the second output of sort and apply that to the second array:
[X, I] = sort(X);
Y = Y(I);
6 件のコメント
Image Analyst
2015 年 4 月 17 日
He said xlsread() sorts them. Why would it do that?
Ken Atwell
2015 年 4 月 17 日
Oh, I missed that. I don't have an explanation then (and I know this code to some degree). Nitin, you'll really need to upload a spreadsheet that demonstrates the problem.
Image Analyst
2015 年 4 月 17 日
Maybe he called xlsread() twice - once for each column - and then actually did call sort() on his own. I guess we'll have to see his actual code and workbook to know for sure.
nitin arora
2015 年 4 月 17 日
編集済み: Image Analyst
2015 年 4 月 17 日
Image Analyst
2015 年 4 月 17 日
Please attach test.xlsx. You probably just clicked the "Choose file" button but forgot to click the "Attach file" button. And just to be clear, you're saying that it is the xlsread() itself that is rearranging/sorting the cells and you are definitely not calling sort() yourself, right?
nitin arora
2015 年 4 月 17 日
編集済み: nitin arora
2015 年 4 月 17 日
カテゴリ
ヘルプ センター および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!