I have multiple spread sheets with multiple sheets that I want to write an indexing data import function for
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
A Poyser
le 8 Déc 2022
Réponse apportée : Mathieu NOE
le 8 Déc 2022
I am trying to plot graphs from three spreadsheets. Each spreadsheet is made up of multiple sheets of varying length, all that are continuously getting loger as I run simulations. I am currently importing each sheet individually and then having to edit the code to find the last value. The code for importing is below.
%
opts = spreadsheetImportOptions("NumVariables", 9);
%%
% Import element factor 8
%%
% Sheet D05 element factor 8
opts.Sheet = "D5";
opts.DataRange = "A2:I64";
%
% Specify column names and types
opts.VariableNames = ["E11", "E22", "E33", "G23", "G13", "G12", "nu23", "nu13", "nu12"];
opts.SelectedVariableNames = ["E11", "G12", "nu12"];
opts.VariableTypes = ["double", "double", "double", "double", "double", "double", "double", "double", "double"];
%
% Import the data
D05_8 = readtable("Y:\Ox-Ox_CMC\Spreadsheets\Reports\ttf_8\ttf8_convergence.xlsx", opts, "UseExcel", false);
This is repeated for the values D05, D15, D25, D35,D45 three times for a mesh element factor of 8,4, and 1. I woudl like to import all of the data with one function that I can then use to draw three graphs, that show a statistical convergence.
I am using either 2022b and/or 2021a
Hopefully someone can help, thanks.
0 commentaires
Réponse acceptée
Mathieu NOE
le 8 Déc 2022
hello
you can probably build your solution from this example
I assume you want to concatenate the data from the 3 sheets ?
% Importing Data from excel across multiple sheets.
filename = 'Aircraft.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};
% ypour own code below...
end
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Spreadsheets dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!