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!