user input for xlsread
8 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi,
I am trying to implement code where the user is asked to choose the range of data they want to import from excel. Here is what I have so far:
clc, clear, close all
[baseFileName, folder]=uigetfile('*.xl*','Specify an Excel file');
fullFileName=fullfile(folder,baseFileName);
[totalRange]=xlsread(fullFileName,-1)
xpos=totalRange(:,2);
track=totalRange(:,1);
frame=totalRange(:,3);
And this is the error I received:
Attempted to access totalRange(:,2); index out of bounds because
size(totalRange)=[65,1].
Error in userxlsread (line 5)
xpos=totalRange(:,2);
Note: In the Excel spreadsheet, the columns that contain the data the user wants are not necessarily adjacent to each other.
When I try the code with columns that are right next to each other, it works. However I would like to get it to work so that the columns of data do not have to be right next to each other.
Thank you.
0 commentaires
Réponses (1)
ES
le 11 Fév 2014
I tried. Supposedly, xlsread with -1 as parameter only reads the adjacent columns. If you choose columns that are not adjacent, it picks only the adjacent columns. Same with the case of rows too.
You might either read the full file and truncate the data as per User's choice.
0 commentaires
Voir également
Catégories
En savoir plus sur Spreadsheets dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!