%
%  hw04polar.m -- (djm: 09 feb 2006)
%

%  initialize workspace
clear;  close all

R = 2;  N = 32;  alph = pi-pi/6;  gap = pi/4;  fudge = 0.02;

%  coordinates
dth = pi/50;  dr = (R-1)/20;
[th,ra] = meshgrid(0:dth:2*pi,1:dr:R);
[xx,yy] = pol2cart(th,ra);

%  my sample solution
load hw04data.mat

%  velocity potential & streamfunction
%  -- PUT YOUR SOLUTION HERE
%
% phi = 0;  psi = 0;
% 
% for jj = 1:N
%     an = 
%     bn = 
% 
%     phi = phi + 
%     psi = psi + 
% end

psiM = [max(psi(:)),min(psi(:))]
phiM = [max(phi(:)),min(phi(:))];

contour(xx,yy,psi,[-1:0.1:1]*max(abs(psiM)),'-','linewidth',2)
hold on
contour(xx,yy,phi,[-1:0.1:1]*max(abs(phiM)),'b--')
colormap(jet);  colorbar
axis equal;  axis([-1 1 -1 1]*1.05*R);

title('\bf hw #4 -- problem A (boring title)','FontSize',14);
xlabel('\bf x-axis','FontSize',14);
ylabel('\bf y-axis','FontSize',14);

contour(xx,yy,psi,[psiM(1)-fudge psiM(2)+fudge],'k','linewidth',2)
contour(xx,yy,psi,[-1 1]*0.0005,'k','linewidth',2)

%  inflow/outflow
gth = 0:dth:gap;  gones = ones(size(gth));
[xr,yr] = pol2cart(     gth,R*gones);
plot(xr,yr,'k--','linewidth',2)
[xr,yr] = pol2cart(alph+gth,R*gones);
plot(xr,yr,'k--','linewidth',2)