How to make structure from Excel

4 ビュー (過去 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 Center および File ExchangeSpreadsheets についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by