Importing Excel file data and creating variables with the imported data
4 views (last 30 days)
Show older comments
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 Comments
Answers (1)
Mathieu NOE
on 5 Dec 2022
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 Comments
See Also
Categories
Find more on Spreadsheets in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!