필터 지우기
필터 지우기

Import excel to matlab

조회 수: 1 (최근 30일)
Ryan Freeman
Ryan Freeman 2011년 7월 18일
I want to import data from excel into matlab. My data is separated into different sheets and I would like to save each sheet into its own variable (it is important that the sheets stay separated, I don't just want to import all the data into a single variable). Does anyone know how to do this?

답변 (1개)

Chirag Gupta
Chirag Gupta 2011년 7월 18일
[~, sheets, ~] = xlsfinfo('myfile.xls'); gives a cell array of sheets
for i = 1:length(sheets)
%create variable string
varname = genvarname('data_' sheets{i});
eval('varname = xlsread(''mytest.xls'',sheets{i})');
end
  댓글 수: 3
Ryan Freeman
Ryan Freeman 2011년 7월 18일
Thank you. I am getting an error at the line vername = genvarname ('data_' sheets {i}).
Chirag Gupta
Chirag Gupta 2011년 7월 19일
My bad! it should be:
varname = genvarname( ['data_' sheets{i} ] );

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

카테고리

Help CenterFile Exchange에서 Data Import from MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by