Spatial-Temporal Contour plot from multi excel files
4 views (last 30 days)
Show older comments
Adi Purwandana
on 18 Oct 2024
Commented: Star Strider
on 19 Oct 2024
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 Comments
Accepted Answer
Star Strider
on 18 Oct 2024
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 Comments
More Answers (0)
See Also
Categories
Find more on Migrate GUIDE Apps in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!