xlsread unable to import data or sorts the imported data. please advice.
1 vue (au cours des 30 derniers jours)
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.
Ken Atwell le 18 Avr 2015
Nitin, I was able to load this 20 times in a row without issue. But, I am on Mac, which uses quite a different code path than a Windows computer (you didn't say what OS you are using), so we may not be making much of a comparison.
Try not to have Excel running on your computer at the same time you run this code. I've heard claims, but never personally verified, that reliability drops when Excel is being used both as a Desktop application and Automation server.
This is a stab in the dark, but try loading the spreadsheet in one command, passing 'basic' as the fourth argument to xlsread. This will cause MATLAB to read the file with its own reader, instead of bridging to Excel using Automation to do the read. The assign the columns to individual variable. Maybe there is some kind of timing issue with running xlsread in rapid succession? That code would look like:
Plus de réponses (1)
Ken Atwell le 17 Avr 2015
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);