필터 지우기
필터 지우기

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 CenterFile Exchange에서 Data Export to MATLAB에 대해 자세히 알아보기

제품


릴리스

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by