Cell Array Dynamic Size
조회 수: 7 (최근 30일)
이전 댓글 표시
Any thoughts would be helpful!
댓글 수: 0
채택된 답변
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
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Export to MATLAB에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!