Cell Array Dynamic Size
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Any thoughts would be helpful!
0 commentaires
Réponse acceptée
Are Mjaavatten
le 25 Juil 2019
If you are happy with storing the data as a matrix for each sheet :
filename = 'Q.xlsx';
n_sheets = 2;
DP = cell(1,n_sheets); % Store data in cell arrays
for i = 1:n_sheets
sheet = ['DP ',num2str(i-1)];
DP{i} = xlsread(filename,sheet);
end
The data for time step k on the second data sheet (DP 1) is now:
DP{2}(17,:)
Variables are stored column-wise, as in the Excel sheet
plot(DP{2}(:,2))
If you want a more flexible data representation, you may create a Matlab struct for each sheet:
for i = 1:n_sheets
sheet = ['DP ',num2str(i-1)];
numdata = xlsread(filename,sheet);
[~,headers] = xlsread(filename,sheet,'A1:M1');
% Create fields for each column:
DP{i}.time = numdata(:,1);
for j = 2:length(headers)
parts = regexp(headers{j},'\s','split'); % Extract the relevant string
varname = parts{3};
DP{i}.(varname) = numdata(:,j);
end
end
plot(DP{2}.time,DP{2}.Fx1)
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Data Export to MATLAB 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!