www.pudn.com > AFEM@matlab.rar > putsolu.m, change:2006-10-17,size:1913b


function putsolu(mesh, filename, format, varargin)
% PUTSOLU saves the current finite element solution to a file with
% designated file name and format. 
% 
% USAGE
%    putsolu(mesh, filename, format, varargin)
%
% INPUT 
%       mesh:  current mesh structure
%   filename:  file name you want to use to save mesh and solution
%     format:  picture format 
%              supported format includes ps, eps, ps2, eps2, jpeg, png,
%              etc (see the help of MATLAB command print), default format
%              is "epsc".
%   varargin:  view angles and other optional parameters
%
% Examples
%    putsolu(mesh)
%    putsolu(mesh, 'savedsolu', 'png')
%    putsolu(mesh, 'savedsolu', 'eps', 30, 10, 'tiff', 'r300')
%

% L. Chen & C. Zhang 10-17-2006

%--------------------------------------------------------------------------
% Generate opitional data
%--------------------------------------------------------------------------
x = 40; y = 15; % default view angle 
if nargin >= 5, y = varargin{2}; end
if nargin >= 4, x = varargin{1}; end

parameters = []; % optional parameters
if (nargin >= 6)
    for i = 3:length(varargin)
        parameters = [parameters, ' -', varargin{i}];
    end
end

if nargin <= 1, filename = 'solufile'; end % default file name
if nargin <= 2, format = 'epsc'; end       % default file format

%--------------------------------------------------------------------------
% Plot and save mesh
%--------------------------------------------------------------------------
fighandle = figure;
trisurf(mesh.elem, mesh.node(:,1), mesh.node(:,2), mesh.solu', ...
        'FaceColor', 'interp', 'EdgeColor', 'interp');
view(x,y);
eval(['print', ' -d', format, parameters, ' ', filename]);
close(fighandle);

%--------------------------------------------------------------------------
% End of function PUTMESH
%--------------------------------------------------------------------------