Cell Array Dynamic Size

7 ビュー (過去 30 日間)
XC
XC 2019 年 7 月 25 日
編集済み: XC 2019 年 8 月 20 日
Any thoughts would be helpful!

採用された回答

Are Mjaavatten
Are Mjaavatten 2019 年 7 月 25 日
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 件)

カテゴリ

Help Center および File ExchangeSpreadsheets についてさらに検索

製品


リリース

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by