-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
124 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
function [] = DirichletBipolar(R1, R2, L, N) | ||
N(1:2)=N; | ||
a=sqrt((R1^2-R2^2)^2-8*L^2*(R1^2+R2^2)+16*L^4)/(4*L); | ||
x1=-asinh(a/R1); | ||
x2= asinh(a/R2); | ||
|
||
[Dx,x]=chebD(N(1)); x=x1+(x2-x1)/2*(x+1); Dx=2/(x2-x1)*Dx; Dxx=Dx*Dx; | ||
[Dyy,y]=periodicD2(N(2)); | ||
[xx,yy]=ndgrid(x,y); | ||
zz=xx+1i*yy; | ||
ww=a*coth(zz/2)-a*coth(x2)+L; | ||
uu=real(ww); | ||
vv=imag(ww); | ||
J=abs(-a/2*csch(zz/2).^2).^2; | ||
F=zeros(N); | ||
|
||
bc=[1+0*y; -1+0*y]; | ||
RHS=J.*F-Dxx(:,[1,end])*bc; | ||
psi=zeros(N); | ||
psi([1,end],:)=bc; | ||
psi(2:end-1,:)=sylvester(Dxx(2:end-1,2:end-1), Dyy', RHS(2:end-1,:)); | ||
|
||
h=mesh(uu(:,[1:end,1]),vv(:,[1:end,1]),psi(:,[1:end,1])); | ||
colormap(jet(256)); shading interp; | ||
set(h,'FaceColor','none'); whitebg(1,'k'); view(2); | ||
c=4*(R1+R2+L); xlim([-c,c]); ylim([-c,c]); | ||
xrange=2*c; | ||
yrange=2*c; | ||
zrange=max(psi(:))-min(psi(:)); | ||
daspect([1 1 2*zrange/hypot(xrange,yrange)]); | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
function [ww] = bipolarMap(R1,R2,L,N) | ||
N(1:2)=N; | ||
a=sqrt((R1^2-R2^2)^2-8*L^2*(R1^2+R2^2)+16*L^4)/(4*L); | ||
x1=asinh(a/R1); | ||
x2=asinh(a/R2); | ||
|
||
x=linspace(-x1,x2,N(1)); | ||
y=linspace(0,2*pi,N(2)); | ||
[xx,yy]=ndgrid(x,y); | ||
zz=xx+1i*yy; | ||
ww=a*coth(zz/2)-a*coth(x2)+L; | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
function [ww] = ellipticMap(a,b,N) | ||
N(1:2)=N; | ||
f=sqrt(a^2-b^2); | ||
xi0=acosh(a/f); | ||
x=linspace(0,xi0,N(1)); | ||
y=linspace(0,2*pi,N(2)); | ||
[xx,yy]=ndgrid(x,y); | ||
zz=xx+1i*yy; | ||
ww=f*cosh(zz); | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
function [] = imhaart() | ||
% Black and white image | ||
X=imread('Lenna.png'); | ||
X=double(X)/255; | ||
|
||
% Gaussian noise | ||
sigma=0.08; | ||
w=sigma*randn(size(X)); | ||
Y=max(min(X+w,1),0); | ||
|
||
% Haar wavelet transform | ||
N=wmaxlev(min(size(X(:,:,1))),'haar'); | ||
[C,S]=wavedec2(Y,N,'haar'); | ||
|
||
% Kill lower coefficients | ||
tol=3*sigma; | ||
CT=C; | ||
CT(abs(C)<tol)=0; | ||
CT(1:3*S(1,1)*S(1,2))=C(1:3*S(1,1)*S(1,2)); | ||
|
||
% Inverse Haar wavelet transform | ||
Z=waverec2(CT,S,'haar'); | ||
|
||
% Show images | ||
figure(1); | ||
imagesc([X,Y,Z]); | ||
axis equal off; | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,20 @@ | ||
function [] = nonlinearODE(n) | ||
[D,x]=chebD(n); | ||
D2=D*D; | ||
|
||
u1=1; | ||
u2=2; | ||
|
||
bc=D2(2:end-1,[1 end])*[u2;u1]; | ||
u=u1+(u2-u1)*(x+1)/2; | ||
|
||
|
||
|
||
i=0; | ||
err=1; | ||
tol=1e-10; | ||
i=0; err=1; tol=1e-10; | ||
while err>tol | ||
unew=D2(2:end-1,2:end-1)\(exp(u(2:end-1))-bc); | ||
err=norm(unew-u(2:end-1),inf); | ||
u(2:end-1)=unew; | ||
i=i+1; | ||
end | ||
fprintf('%d iterations\n',i); | ||
h=plot(x,u); | ||
plot(x,u); | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
function [] = sinegordon( N ) | ||
[D,x]=chebD(N); t=1+x'; | ||
Dxx=D*D; | ||
Dtt=D*D; | ||
Dtt(1,:)=D(end,:); | ||
|
||
u=zeros(N); | ||
ut0=-0*exp(-10*x.^2); | ||
u(:,1)=ut0; | ||
u(:,end)=exp(-10*x.^2); | ||
BC=Dxx*u-u*Dtt'; | ||
|
||
i=0; err=1; tol=1e-10; | ||
while err>tol | ||
unew=sylvester(Dxx(2:end-1,2:end-1), -Dtt(1:end-1,1:end-1)', [ut0(2:end-1), sin(u(2:end-1,2:end-1))]-BC(2:end-1,1:end-1)); | ||
err=norm(unew-u(2:end-1,1:end-1),inf); | ||
u(2:end-1,1:end-1)=unew; | ||
i=i+1; | ||
|
||
end | ||
[xx,tt]=ndgrid(x,t); | ||
surf(xx,tt,u); colormap(jet(256)); view(2); | ||
end | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
function [pp] = noise(p,t) | ||
p=p+randn(size(p)); | ||
p_hat=fft(p); | ||
pp=sqrt(2*pi)/length(p)*ifft(conj(p_hat).*p_hat); | ||
plot(t, [pp; cos(t)*sqrt(pi/2)]); | ||
pr=p+randn(size(p)); | ||
p_hat=fft(pr); | ||
pp=2/length(p)*ifft(conj(p_hat).*p_hat); | ||
plot(t, [pp; p]); | ||
end | ||
|