Home > demos > schnakenberg > four.m

four

PURPOSE ^

script for Fourier plots: adapt by hand

SYNOPSIS ^

This is a script file.

DESCRIPTION ^

 script for Fourier plots: adapt by hand 
 load point, interpolate to rect. grid, subtract the mean, FFT

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 % script for Fourier plots: adapt by hand
0002 % load point, interpolate to rect. grid, subtract the mean, FFT
0003 load('c/p5');
0004 nx=4*round(sqrt(p.np)); ny=nx; x=p.points(1,:)'; y=p.points(2,:)';
0005 xmin=min(x); xmax=max(x); ymin=min(y); ymax=max(y); 
0006 xg=linspace(xmin,xmax,nx);yg=linspace(ymin,ymax,ny); % "grid"
0007 kg=-nx/2:1:nx/2-1; lg=-ny/2:1:ny/2-1; % F-vectors (normalized to 2pi)
0008 cmp=1; u1=p.u(1+(cmp-1)*p.np:cmp*p.np); 
0009 ugg=tri2grid(p.points,p.tria,u1,xg,yg); % interpol to grid
0010 um=sum(sum(ugg))/nx/ny; ug=ugg-um; % subtract mean
0011 uf=fftshift(fft2(ug))/nx/ny; % normalized FT
0012 kf=2*pi/(xmax-xmin); lf=2*pi/(ymax-ymin); % scaling factors since FFT
0013 % assumes 2pi periodicity
0014 %% the actual plotting: choose cutoff's for Fourier plots
0015 figure(6);clf; kc=5; lc=3; % cutoffs for plot!
0016 kvec=(kg(nx/2-kc+2:nx/2+kc+1)-0.5)*kf; lvec=(lg(ny/2-lc+2:ny/2+lc+1)-0.5)*lf; 
0017 pcolor(kvec,lvec,(abs(uf(ny/2-lc+2:ny/2+lc+1,nx/2-kc+2:nx/2+kc+1))).^0.5); 
0018 axis equal;axis tight;colorbar; grid off; colormap(hot); shading flat;
0019 % Alternatively use mesh
0020 %mesh(kvec,lvec,abs(uf(ny/2-lc+2:ny/2+lc+1,nx/2-kc+2:nx/2+kc+1)));
0021 fs=16;title(['Fourier coeff. at ',str],'Fontsize',16); set(gca,'fontsize',16)
0022

Generated on Wed 15-Aug-2012 12:53:02 by m2html © 2005