source: anuga_validation/convergence_study/animatesww2d_alt.m @ 5300

Last change on this file since 5300 was 4698, checked in by sexton, 17 years ago

(i) commented matlab script from William (ii) scripts looking at grad data

File size: 1.7 KB
Line 
1function animatesww2d_alt(sww_filename,movie_filename,range)
2
3nc2mat(sww_filename,'swwtemp.mat'); %convert .sww to .mat
4
5load('swwtemp.mat'); % load the data from the temporary .mat file
6
7figure(1); % Create a new figure
8
9if nargin > 1
10    % If we're making an animation then set the figure location and prepare
11    % the avi file
12    figure(1);set(gcf,'Position',[200 400 800 300]);
13    mov=avifile(movie_filename,'FPS',5)
14end
15
16i=find(V_y==0); % Find all the points which lie along the x-axis
17                % This could be made more general, or done in a way that is
18                % safer against rounding-off errors.
19                %
20                % 'i' becomes a vector containing the indices of those points
21                % which are on the x-axis.
22
23if nargin < 3
24    % If we don't specify the range to plot on the axes, then set it
25    % here. X-axis covers the range in V_x, and the y-axis is 1 metre
26    % outside the range of values in V_stage.
27    range=[min(V_x) max(V_x) min(min(V_stage))-1 max(max(V_stage))+1];
28end
29
30m=V_stage(1,i); % m is the vector containing the maximum stage values found
31                % so far among the points selected with 'i'.
32
33for t=1:length(V_time)
34   
35    m=max(m,V_stage(t,i)); % update the vector of maximum values
36   
37    plot(V_x(i),V_stage(t,i),V_x(i),V_elevation(i),V_x(i),m,'.');
38    % Plot the stage of the points that are selected using the vector 'i'
39   
40    axis(range)
41    % set the range of the axes
42
43    title(num2str(V_time(t)));drawnow;
44    % label with the time
45   
46    if nargin>1
47        % If we're making an animation then add a new frame
48        F=getframe(gcf);
49        mov=addframe(mov,F);   
50    end
51   
52end
53
54if nargin > 1
55    % Close the animation file if necessary
56    mov=close(mov);
57end
Note: See TracBrowser for help on using the repository browser.