function giffoil(filename) % This is a simple matlab plotting function for use with the % airfoil data files obtained from the % University of Illinois at Urbana-Champaign % % usage: % pf('filename') % note .dat extension is assumed % datafile = [filename '.dat']; giffile = ['gifs/' filename '.gif']; fid = fopen(datafile,'r'); if (fid == -1) fprintf(1,'error opening %s\n',datafile); return; end name = fgetl(fid); [pts,count] = fscanf(fid,'%f'); fclose(fid); if ( (pts(1) == floor(pts(1))) & (pts(1)>5) ) % "Lednicers" format npts_top = pts(1); npts_bot = pts(2); top = zeros(2,npts_top); bot = zeros(2,npts_bot); tp = pts(3:2+2*npts_top); bt = pts(3+2*npts_top:2+2*npts_top+2*npts_bot); top(:) = tp; bot(:) = bt; h=figure('visible','off'); plot(top(1,:),top(2,:),'w'); hold on plot(bot(1,:),bot(2,:),'w'); axis([0 1 -.5 .5]); title(name); elseif (length(pts)/2 == floor(length(pts)/2)) % "selig" format assumed... npts = length(pts)/2; foil = zeros(2,npts); foil(:) = pts; h=figure('visible','off'); plot(foil(1,:),foil(2,:),'w'); axis([0 1 -.5 .5]); title(name); else % n x y format assumed npts = length(pts)/3; if (npts ~= floor(npts)) fprintf(1,'error interpreting %s\n',datafile); return; end foil = zeros(3,npts); foil(:) = pts; h=figure('visible','off'); plot(foil(2,:),foil(3,:),'w'); axis([0 1 -.5 .5]); title(name); end status = 0; axis([0 1 -0.5 0.5]); set(gcf,'paperposition',[0 0 7.2 6.8]); print -dps figure.ps close; gsfname = 'gs.cmd'; gsfid = fopen (gsfname, 'w'); fprintf(gsfid,'-dNOPAUSE -q\n'); fprintf(gsfid,'-I/packages/matlab/ghostscript/ps_files\n'); fprintf(gsfid,'-I/packages/matlab/ghostscript/fonts\n'); fprintf(gsfid,'-sDEVICE=gif8\n'); fprintf(gsfid,'-g500x500\n'); fprintf(gsfid,'-sOutputFile=%s\n',giffile); fclose(gsfid); status=unix('/packages/matlab/ghostscript/bin/sun4/gs @gs.cmd figure.ps /dev/null'); if (status ~=0) fprintf(1,'unix status %i\n', status); else fprintf(1,'%s converted ok\n',datafile); end return