How to make structure from Excel

조회 수: 3 (최근 30일)
Giorgi
Giorgi 2014년 9월 2일
댓글: Giorgi 2014년 9월 2일
Hello, Well I am working on structures and have some kind of problem, I have excel file that contains some kinds of data in each sheet, I want to write a code that will make the same number of structures as sheets, after that it should divide each sheets into the variables and than this variables should assigned in its structure. For example I have excel file with three sheet, these sheets contains data first second and third, my goal is to make code three structure i mean sheet1 sheet2 and sheet3 and each structure should contain first second and third variables. Well the last problem is solved I mean division excel file into variables but I am not be able to make structures that will contain these variables. Waiting for your respones any idea would be great for me.

채택된 답변

Andrei Bobrov
Andrei Bobrov 2014년 9월 2일
편집: Andrei Bobrov 2014년 9월 2일
for ii = 3:-1:1
[d,T] = xlsread('example.xlsx',ii);
z = [strtrim(T); num2cell(d,1)];
s(ii) = struct(z{:});
end
or
T = {'First' 'Second' 'Third'};
for ii = 3:-1:1
d = xlsread('example.xlsx',ii);
z = [T; num2cell(d,1)];
s(ii) = struct(z{:});
end
  댓글 수: 3
Andrei Bobrov
Andrei Bobrov 2014년 9월 2일
편집: Andrei Bobrov 2014년 9월 2일
A whitespace in the name field. Corrected.
Giorgi
Giorgi 2014년 9월 2일
That works! Thanks a lot :)

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

추가 답변 (0개)

카테고리

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