Undefined function or method 'H' for input arguments of type 'double'.
2 views (last 30 days)
Show older comments
Hi guys.
Why does the following error comes? what is wrong?
??? Undefined function or method 'H' for input arguments of type 'double'.
Error in ==> yeniyazi2FT at 45
H(j)=fftshift(H(j));
close all
clear all
clc
x_1=linspace(-1,1,5);
y_1=linspace(-1,1,5);
z=0.5;
L1=0.5;
lambda=1030e-9;
k=2*pi/lambda;
w0=0.1;
zr=pi*w0.^2/lambda;
R=z*(1+(zr/z).^2);
w=w0*sqrt(1+(z/zr)^2);
[x1,y1]=meshgrid(x_1,x_1);
u1=w0/w.*exp(-(x1.^2+y1.^2).^2/w.^2).*exp(-1i*k*z).*exp(-1i*k*(x1.^2+y1.^2).^2/(2*R));
j=sqrt(-1);
L=0.25;
[M,N]=size(u1); % get inpute field array size
dx=L/M; % sample interval
k=2*pi/lambda; %wavenumber
fx=-1/(2*dx):1/L:1/(2*dx)-1/L; %freq coords
[FX,FY]=meshgrid(fx,fx);
x2=x1; %obs coords
y2=y1;
H=exp(-1i*pi*lambda*z*(FX.^2+FY.^2)); %trans func
for j=1:5
H(j)=fftshift(H(j));
u(j)=fft2(fftshift(u(j)));
u(j+1)=H(j).*u(j);
u(j+1)=ifftshift(ifft2(u(j+1))); end
Answers (1)
Azzi Abdelmalek
on 17 Nov 2014
u is not defined.
x_1=linspace(-1,1,5);
y_1=linspace(-1,1,5);
z=0.5;
L1=0.5;
lambda=1030e-9;
k=2*pi/lambda;
w0=0.1;
zr=pi*w0.^2/lambda;
R=z*(1+(zr/z).^2);
w=w0*sqrt(1+(z/zr)^2);
[x1,y1]=meshgrid(x_1,x_1);
u1=w0/w.*exp(-(x1.^2+y1.^2).^2/w.^2).*exp(-1i*k*z).*exp(-1i*k*(x1.^2+y1.^2).^2/(2*R));
j=sqrt(-1);
L=0.25;
[M,N]=size(u1); % get inpute field array size
dx=L/M; % sample interval
k=2*pi/lambda; %wavenumber
fx=-1/(2*dx):1/L:1/(2*dx)-1/L; %freq coords
[FX,FY]=meshgrid(fx,fx);
x2=x1; %obs coords
y2=y1;
H=exp(-1i*pi*lambda*z*(FX.^2+FY.^2)); %trans func
for j=1:5
H(j)=fftshift(H(j));
u(j)=fft2(fftshift(u1(j)));
u(j+1)=H(j).*u(j);
u(j+1)=ifftshift(ifft2(u(j+1)));
end
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!