Read many column from excel sheet

조회 수: 1 (최근 30일)
Ali Jaber
Ali Jaber 2016년 4월 3일
댓글: MBD4FUN 2016년 4월 3일
I have to read from an excel sheet many columns, and each column has to be assigned to a variable, for example first column is firstmatrix, etc. I wrote the following code but it only read one column. I have no idea how can I read all columns not manually!
[filename, pathname] = uigetfile('*.xlsx','Load Dataset');
if filename==0
msgbox('Please Choose Dataset','Error','Error')
return
end
A = xlsread(filename,'Sheet1','C17:C46');
disp(A);
  댓글 수: 1
MBD4FUN
MBD4FUN 2016년 4월 3일
Why don't you just read the entire sheet and extract data by column later? Don't know if the following is what you want but might give you some hint.
% Get all data from sheet
[~,~,alldata] = xlsread(filename,'Sheet1');
% Set column to variables
A = alldata(:,1);
B = alldata(:,2);
...etc,.
Or simply using a for-loop to iterate through columns of the alldata cell array to get what you are looking for.
Happy Scripting!
MBD4FUN

댓글을 달려면 로그인하십시오.

답변 (1개)

Azzi Abdelmalek
Azzi Abdelmalek 2016년 4월 3일
If you want all columns
A = xlsread(filename);

카테고리

Help CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by