⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 plotslab.m

📁 利用C
💻 M
字号:
% Copyright (C) 2003-2005 Anders Logg.% Licensed under the GNU LGPL Version 2.1.%% First added:  2003-11-07% Last changed: 2005function M = plotslab(debugfile, interval, drawupdates, drawtext, saveps, savepng)% Usage: M = plotslab(debugfile, interval, drawupdates, drawtext, saveps, savepng)%% Draws and creates a movie M of a time slab. A debug file% is created by DOLFIN when the option 'debug time steps'% is specified.%% Arguments:%%   debugfile   - name of file containing time stepping data%   interval    - plot elements within interval%   drawupdates - blink element updates%   drawtext    - draw extra text%   saveps      - save a postscript file for each frame%   savepng     - save a png file for each frame%% Copyright (C) 2003 Johan Hoffman and Anders Logg.% Licensed under the GNU LGPL Version 2.1.% Load the stepsdisp('Loading file...')timesteps = load(debugfile);% Get the number of componentsN  = max(timesteps(:,2)) + 1;% Get the time intervalT1 = interval(1);T2 = interval(2);% Create figureclfaxis([T1 T2 -0.3*N 1.2*N])axis offhold onif drawtext  h1 = text(T1,1.1*N,'Action:');  h2 = text(T1,-0.1*N,['t = ' num2str(T1)]);  h3 = text(T1,-0.15*N,['i = ' num2str(0)]);endplot([T1 T2],[0 0],'k');framecount = 1;iterations = 0;% Clear the movieclear M% Step to the correct positionfor i = 1:size(timesteps,1)  a  = timesteps(i,1);  n  = timesteps(i,2);  t1 = timesteps(i,3);  t2 = timesteps(i,4);   if t2 >= T1    break;  endend% Draw the elementsfor j = i:size(timesteps, 1)  % Get next element  a  = timesteps(j,1);  n  = timesteps(j,2);  t1 = timesteps(j,3);  t2 = timesteps(j,4);  % Go to next element if we don't want to draw updates  if ~drawupdates & a == 1    continue  end    % Check if we have finished  if t1 > T2    break  end  % Check action  switch a    case 0            % Draw a new box      %c = [128 156 178]/256;      c = 'b';      drawbox([t1 n], [t2 (n+1)], c);      % Draw text      if ( drawtext )	set(h1, 'String', 'Action: Creating new element')	set(h2, 'String', ['t = ' num2str(t1)])	set(h3, 'String', ['i = ' num2str(n)])      end    case 1      % Blink box      %c = [0 98 178]/256;      c = 'r';      cc = [250 130 180]/256;      drawbox([t1 n], [t2 (n+1)], c);      % Draw text      if ( drawtext )	set(h1, 'String', 'Action: Updating element')	set(h2, 'String', ['t = ' num2str(t1)])	set(h3, 'String', ['i = ' num2str(n)])      end            % Save frame      drawnow      M(framecount) = getframe;      if saveps	print('-depsc', ['frame_' sprintf('%.4d', framecount) '.eps'])      elseif savepng	print('-dpng', '-r0', ['frame_' sprintf('%.4d', framecount) '.png'])      else	disp('Press any key to continue')	pause      end		        framecount = framecount + 1;      % Restore box      %c = [128 156 178]/256;      c = 'b';      drawbox([t1 n], [t2 (n+1)], c);  end      % Save frame  drawnow  M(framecount) = getframe;  if saveps    print('-depsc', ['frame_' sprintf('%.4d', framecount) '.eps'])  elseif savepng    print('-dpng', '-r0', ['frame_' sprintf('%.4d', framecount) '.png'])  else    disp('Press any key to continue')    pause  end		    framecount = framecount + 1;  endfunction drawbox(x, y, c)% This function draws a box from x to y with color cx1 = [x(1) y(1) y(1) x(1)];x2 = [x(2) x(2) y(2) y(2)];fill(x1, x2, c)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -