Spatial-Temporal Contour plot from multi excel files
조회 수: 5 (최근 30일)
이전 댓글 표시
Hello there,
I have four groups of datasets (in excel files, attached). Let’s say they are: data_A1, data_A2, data_A3, data_A4. Each of them contains 3 parameters, namely ax, ay, and az. To make it easily imagined in space-time perspective, let’s say ax is the variable of time and ay is the variable of depth and az is the variable I'd like to plot its spatial-temporal variability. My intention is to get a contour plot of those datasets, representing the spatial-temporal evolution of variable az. So, the contour will plot data ax in x-axis, ay in y-axis, and az value presented by the colormap.
Note that:
- There may be a possibility of overlapping/similar values of ay (depth) between data_A1, data_A2, data_A3, data_A4. In this case, I just need the first record to be considered; or maybe if any other proper handling you could suggest, please welcome.
- There also may be blank values of az.
Thanks!
댓글 수: 0
채택된 답변
Star Strider
2024년 10월 18일
I am not certain what you want.
As a first approach, this presents them as surfaces —
files = dir('*.xlsx');
for k = 1:numel(files)
filename = files(k).name
T{k} = readtable(filename);
T{k}
[Tstart,Tend] = bounds(T{k}.ax)
dn{k} = datenum(T{k}.ax);
DN{k} = linspace(min(dn{k}), max(dn{k}), numel(dn{k}));
AY{k} = linspace(min(T{k}.ay), max(T{k}.ay), numel(T{k}.ay))
end
for k = 1:numel(files)
Fcn{k} = scatteredInterpolant(dn{k}, T{k}.ay, T{k}.az);
[AX{k},AY{k}] = ndgrid(DN{k},AY{k});
AZ{k} = Fcn{k}(AX{k},AY{k});
end
% figure
% hold on
for k = 1:numel(files)
figure
surfc(AX{k}, AY{k}, AZ{k}, 'EdgeColor','none')
colormap(turbo)
colorbar
xlabel('ax')
ylabel('ay')
zlabel('az')
title(extractBetween(files(k).name,'_','.'))
end
% hold off
It is necessary to use datenum here because scatteredInterpolant does not work with datetime arrays.
If plotted on the same axes, these appear as flat ribbons with respect to ‘az’, and lose their depth (at least in a relative sense). You can of course plot them as contour plots, however I am at a loss as to how to present them in a ‘spatio-temporal perspective’. Animating them will not show here, and it would be difficult to interpolate them over a smooth time scale in any event, in part because their sizes are not the same (although that could be standardised). The other option is to subtract them serially.
.
댓글 수: 8
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!