To those of you who are interested in enhancing the way you present data using Matlab, possible avenues include changing the viewpoint specification (i.e. the elevation and azimuth) of the figure or creating a movie (or both). The following is a simple example to demonstrate how to accomplish both changing the view of the figure while simultaneously creating a video of the process.
In my current research I am investigating atmospheric temperature disturbances and the data set I am using involves 37 (2D) layers of the atmosphere. When discussing my work with colleagues it is important to properly explain what is happening at each atmospheric layer. A good way to do this is to create a movie that starts with the lowest atmospheric layer (surface level) and build an atmospheric profile by adding more layers one at a time. Here is some pseuo Matlab code to help perform this task:
(Note that each number from 1-19 represents the equivalent line number of code)
- j=0; %This is the atmospheric layer number, which could also represent height
- for i = 1:37 %This will iterate through each of the 37 layers
- h= plot(data(i)); %Plot the data associated with the i-th layer
- z = get(h,’ZData’,) + j; %This will specify the placement of the 2D plot on a z-axis
- set(h,’ZData’,z); %Set the data at the current iteration to the specified height
- j=j+1;
- view(0,50); %This will change the view of the data, where the first number represents the azimuth and the second is the elevation
- drawnow %Display the current iteration’s plot
- videoframe(j) = getframe(gcf); %This will store the current frame to the j-th element of the filename ‘videoframe’
- end
- for i = 1:360 %Next let’s rotate the atmospheric column 360 degrees
- view=(i,50) %At each iteration we change the azimuth while keeping height the same
- drawnow
- j=37+i; %Be careful not to overwrite any of the past frames
- videoframe(j) = getframe(gcf);
- end
- my_video = VideoWriter(‘video_name.avi’); %Call the video writer function and specify the name of the video and format
- open(my_video);
- writeVideo(my_video,videoframe); %Write your video frames stored in ‘videoframe’ to ‘video_name.avi’
After running this code with your own data you should have an AVI movie that builds a 37 layer atmospheric profile and then rotates the image around 360 degrees. If you find the video runs too quickly try adding more video frames at each iteration.
If you have any further questions please don’t hesitate to ask.
Happy plotting!
