


Plots a wave parameter on unstructured grid
Example:
SWAN generated a binary Matlab file called 'f32har01.mat'
TRIANGLE generated files with basename 'f32hari', e.g. 'f32hari.ele'
To make a plot of the significant wave height, give the following
command in Matlab:
plotunswan('f32har01','f32hari','Hsig')
For other wave parameters, type the following command:
who -file f32har01
Author : Marcel Zijlema
Date : February 13, 2008
Version : 1.0

0001 function plotunswan(matfile,basename,wavepar); 0002 % Plots a wave parameter on unstructured grid 0003 % 0004 % Example: 0005 % 0006 % SWAN generated a binary Matlab file called 'f32har01.mat' 0007 % TRIANGLE generated files with basename 'f32hari', e.g. 'f32hari.ele' 0008 % To make a plot of the significant wave height, give the following 0009 % command in Matlab: 0010 % 0011 % plotunswan('f32har01','f32hari','Hsig') 0012 % 0013 % For other wave parameters, type the following command: 0014 % 0015 % who -file f32har01 0016 % 0017 % 0018 % Author : Marcel Zijlema 0019 % Date : February 13, 2008 0020 % Version : 1.0 0021 0022 if nargin~=3 0023 error('Wrong number of arguments. See "help plotunswan"') 0024 end 0025 0026 eval(['load ' matfile]); % load binary file containing SWAN results 0027 % obtained using BLOCK command with COMPGRID-set 0028 elefile=[basename '.ele']; 0029 fid = fopen(elefile); % load TRIANGLE element based connectivity file 0030 [nelem] = fscanf(fid,'%i',[1 3]); % get number of triangles 0031 tri = fscanf(fid,'%i',[4 nelem(1)])'; % get connectivity table 0032 z=eval([wavepar]); % get wave parameter 0033 trisurf(tri(:,2:4),Xp,Yp,z) % make plot using trisurf 0034 view(0,90);shading interp; % make 2D view and smooth plot 0035 colormap(jet);colorbar;axis equal % include colorbar and equal axes