Plot a contour that changes with respect to time
12 views (last 30 days)
Show older comments
I am trying to plot a countour graph that changes with respect to time.
I have a 188x194x1317 matrix (long,lat,time), for each point, there is an elevation.
I have also have the long matrix that is 188x194, a lat matrix that is 188x194, and a time matrix that is 1317x1.
How can I use these pieces to create a contour plot that changes with respect to time?
0 Comments
Accepted Answer
Walter Roberson
on 26 Apr 2019
Edited: Walter Roberson
on 26 Apr 2019
[~,ch] = contour(long, lat, YourMatrix(:,:,1));
drawnow();
dt = diff(YourTimes);
for timestep = 2: size(YourMatrix,3)
pause(dt(timestep-1));
ch.ZData = YourMatrix(:,:,timestep);
drawnow();
end
3 Comments
Walter Roberson
on 26 Apr 2019
[~,ch] = contour(long, lat, YourMatrix(:,:,1));
timefactor = 1/10;
dt = [0; diff(YourTimes) * timefactor];
for repeats = 1 : 100
for timestep = 1: size(YourMatrix,3)
pause(dt(timestep));
ch.ZData = YourMatrix(:,:,timestep);
title( sprintf('time = ', YourTimes(timestep)) )
drawnow();
end
end
Note that the way we encode the time dimension is to wait between frames as long as the time matrix says (well, the difference between the times really.) If the time matrix says [0.01 0.1 1 10] then it would show the first frame for 0.01 seconds, the second for 0.09 seconds (total 0.1 so far), the third for 0.9 seconds (total 1 so far), the fourth for 9 seconds (total 10 so far.) Though in this version, these times are scaled by the timefactor you specify. Humans are pretty bad at judging the passage of time, but you do what you can.
An alternative would be to color the contours according to the passage of time, so for example 35/255 red could be the hint that you are 35/255 of the way through the total time interval, but the frames would be played at constant rate. In the above example of [0.01 0.1 1 10], that would mean that the first two frames were nearly black in contours, that the third frame would be about red 25 (dull but visible), and then suddenly you would just suddenly jump to full brightness of red to convey that the frame was associated with the complete time.
I do not recommend either of these approaches. I think it would make more sense to interpolate the data over time to get a constant time interval between frames, and then play the frames at a constant rate.
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!