Unrecognized function or variable 'delta1'.
1 回表示 (過去 30 日間)
古いコメントを表示
Hello! Whenever I run the following code, the error Unrecognized function or variable 'delta1' appears. Anyone who can help me I would be very grateful.
clear all;
clc;
%ccd to sorce = 17 cm
% ccd to object = 2 cm
% object to source = 15 cm
% size of image pixel and dimension
N = 423;%input ('Size Pixel NxN pixel=');
% M = 736;
L = N*7.00e-6/2;
%wavelength
wvl = 0.650e-6;
k = 2*pi/wvl;
%Dz = 0.03;
awal = 0; %input ('initial position (m) = ');
batas = 0.025; % input ('batas jarak rekontruksi (m) dari 0 ~ ');
%---------------Loop to create images
step = 0.0005;%input ('step size (m) = ');
for Dz=awal:+step:batas
[x1, y1]=meshgrid((-N/2:N/2-1)*delta1);
%Reconst(:,:,c)=dum(floor(hol_size(1)/2)+1:3*floor(hol_size(1)/2),floor(hol_size(2)/2)+1:3*floor(hol_size(2)/2));
[data] = imread('jojo.jpg');
datared = data (1:N,1:N, 1);
%imshow(datared);
%array refrence wave
m1=one(sixe(x1));
kx = k*x1/Dz;
ky = k*y1/Dz;
%dataf = double(datared)-mean2(double(datared));
%dataf = double(max(max(datared)))-double(datared);
%dataf = exp (-1i*k*Dz*double(datared));%-mean2(datared);
%dataf = exp (-2*pi*1i.*(kx+ky).*double(datared));
dataf = double(datared);
r=sqrt(0.17^2*m1 + x1.*xq+y1.*y1);
%Uref = exp (1i*2*pi)./r;
%Uref = 2*pi/wvl;
%lensa = exp
lensa = exp(-1i*k*Dz-(1i*k* (x1.*x1+ y1.*y1)/1i*k*Dz)); % (2*0.02));
filter = exp(-2*pi*1i.*(kx*0.02+ky*0.02));
%datai= dataf. *Uref;
datai = dataf; %.*filter;
[Uot] = fresnel3 (datai, L, wvl, Dz);
reall = Uout.*Uout;
imaginary = imag (Uout.*Uout);
%datao = imag (Uout);
%datao = real (reall) + imaginary;
%datao = atan (imag (Uout)./real (Uout));
datao = abs (Uout).*abs (Uout);
%datao= real (Uout. *Uout) +imag (Uout. *Uout);
%imshow (uint8 (200*datao/max (max (datao))));
imagesc ((uint8 (200*datao/max (max (datao))))), colormap (gray); axis equal; axis tight; ylabel('pixels');
xlabel(['Nilai Dz =',num2str(Dz),'m']);
title(' Image reconstructed by Fresnell Transform ')
%imwrite (uint8 (200*datao/max (max (datao))), sprintf( 'benang_%02d.jpg', Dz));
imwrite (uint8 (200*datao/max (max (datao))), sprintf( 'ini_real_%02d.jpg', Dz ));
disp('Press any key to continue... ');
pause;
end
function [u2] = fresnel (u1, L, lambda, ~)
[M,~] = size (u1);
dx = L/M;
k = 2*pi/lambda;
fx = -1/(2*dx): 1/L:1/(2* dx)-1/L;
[FX, FY] = meshgrid(fx, fx);
H = exp(-i*pi* lambda*z* (FX.^2 + FY.^2));
H = fftshift (H);
U1 = fft2(fftshift (u1));
U2 = H.*U1;
u2 = ifftshift (ifft2 (U2));
end
2 件のコメント
Jan
2023 年 3 月 15 日
Whenever you mention an error in the forum, care for attaching a copy of the complete error message. Then the readers do not have to search or to guess, which line of code is concerned.
採用された回答
Jan
2023 年 3 月 15 日
編集済み: Jan
2023 年 3 月 15 日
Exactly as the error message tells you: The variables or function "delta1" is not defined. Then this linemust fail:
[x1, y1]=meshgrid((-N/2:N/2-1)*delta1);
Fix this by defining delta1.
By the way, what is "one()" and "sixe()"?
m1=one(sixe(x1));
Do you mean:
m1 = ones(size(x1));
その他の回答 (1 件)
Bhanu Prakash
2023 年 3 月 15 日
編集済み: Bhanu Prakash
2023 年 3 月 15 日
Hi Mia,
As per my understanding, you are facing an error while running your code.
The reason is that “MATLAB” does not recognize the specified term “delta1” as the name of a function on the “MATLAB” path or as a variable.
This error usually occurs when the variable/function has not been defined before the execution reaches it’s instance.
Please look at the code below, for your reference:
>> a=1;
>> b=2;
>> d=a+b+c;
Unrecognized function or variable 'c'.
In the above code, “c” is not declared but it is used to compute “d”. This throws an error.
This error can be avoided by defining “c” before computing “d”:
>> a=1;
>> b=2;
>> c=3;
>> d=a+b+c
d =
6
See this documentation for more tips:
Hope this answer helps you.
Thanks,
Bhanu Prakash.
参考
カテゴリ
Help Center および File Exchange で Workspace Variables and MAT-Files についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!