Importing Excel file data and creating variables with the imported data
조회 수: 4 (최근 30일)
이전 댓글 표시
My project group were given an excel spreadsheet with columns of 10 flight conditions with rows being the variables within the flight conditions (airspeed, weight, Cl_alpha, etc.). There are 52 rows and 10 colummns and it will be tedious to hand type in the data.
We are looking for a efficient way to import the data, organize it into individual flight conditions (FC1, FC2, FC3,..., FCn) or have all of the variables be made into arrays for each flight condition so that we can call the flight condition we want to analyze. Is there a way to do that?
I have attached the excel file. We are using the Diamond DA40 sheet for data as reference.
댓글 수: 0
답변 (1개)
Mathieu NOE
2022년 12월 5일
hello
work with tables or structures...(read doc / help sections if your are not familiar with them )
here a starter
% Importing Data from excel across multiple sheets.
filename = 'Aircraft S&C Derivatives (1).xlsx';
[~,sheet_name]=xlsfinfo(filename);
nsheets = numel(sheet_name);
% retrieve raw data
for k = 1:nsheets % nsheets
T{k} = readtable(filename,"Sheet",sheet_name{k}); % table
S{k} = table2struct(T{k},'ToScalar',true); % convert table 2 structure : NB : converts the table T to a scalar structure S.
% Each variable of T becomes a field in S.
S{k}.Name = sheet_name{k}; % here I use the sheet name to name the structure
% your own code below...
end
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Import from MATLAB에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!