Hovmoller Diagram: longitude (x axis), time (y axis), and z(temperature values)
Show older comments
Hi,
I wuold like to extract temperature from a 3D matrix temp 609x881x372 (lonxlatxtime) and do an Hovmoller plot where I have time on the y-axis and longitude on the x-axis (see figure).

I created a logical matrix of 0 and 1 to identify where my coordinates meet my condition:
coord = (aa_lon>=-7 & aa_lon<=9 & aa_lat>=79 & aa_lat<=79.01);
coord is 609x881 logical but my matrix (temp) from which I want to extract the data is 609x881x372 double.
Hope my question is clear.
Please help me :)
Accepted Answer
More Answers (1)
hello
maybe this ?
I created some dummy data to test my code
hope it helps
%% dummy data 609x881x372 (lonxlatxtime)
aa_lon = -45:0.1:60.9-45-0.1;
aa_lat = 0:0.1:88.1-0.1;
p = 10*12;% 10 years of monthly data = 120 time steps
for k = 1:p
data(:,:,k) = rand(609,881) + sin(0.1*k)*ones(609,881);
end
%% spatial filtering
% coord = (aa_lon>=-7 & aa_lon<=9 & aa_lat>=79 & aa_lat<=79.01);
% equivalent to :
a = (aa_lon>=-7 & aa_lon<=9);
b = (aa_lat>=79 & aa_lat<=79.01);
coord = logical(a'*b);
%% main code
[m,n,p] = size(data);
dt = 1; % put here the time increment or use a time vector if it exist
out = [];
% main loop
for k = 1:p
tmp = data(:,:,k);
tmp = tmp(coord); % spatial filtering of the data
time(k) = k*dt;
% time concatenation of the tmp data
out = [out; tmp']; % nb transpose of tmp to have data as row
end
% plot
x_plot = aa_lon(a);
imagesc(x_plot,time,out);
xlabel('Longitude');
ylabel('Time (months)');
4 Comments
Carlotta Dentico
on 5 Sep 2023
Mathieu NOE
on 11 Sep 2023
hello
can you share your data (as mat file) ?
Carlotta Dentico
on 11 Sep 2023
Mathieu NOE
on 13 Sep 2023
see my answer in the answer section below !
Categories
Find more on Creating and Concatenating Matrices 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!

