problem with defining variable
Show older comments
Hi,
I've a problem with following code. I try to define 4 variables in 2 while loops: Gamma5, tau5 and Gamma and tau
For Gamma5 en tau5 I get the matrix correctly.
But for Gamma en tau, ( I do exactly the same for tau and Gamma) I get following error:
*
"Undefined function or variable 'Gamma'. "*
Does somebody know how to solve this?
Thanks in advance!
N =10
omega =90;
x= -0;
y= -0;
i = 0;
j = 0;
a = 11.35
b = 5.40
c = 8.60
d = 11.35/(2*N)
d2 = 5.40/(2*N)
d3 = 8.60/(2*N)
pz =2000
hG = 0.1; %(pz/2h)
while (x <= a)
while (y <= b)
Gamma5(i+1,j+1) = sqrt(sind(omega)^2 + hG^2*(x.^2+y.^2-2*x.*y.*cosd(omega)))
tau5(i+1,j+1) = (1/2)*(-pz/hG)*Gamma5(i+1,j+1)
j =j+1;
y= y+d2;
end
y = 0; %-a
j = 0;
x= x+d;
i= i+1;
end
while (x <= a)
while (y <= b)
Gamma(i+1,j+1) = sqrt(sind(omega)^2 + hG^2*(x.^2+y.^2-2*x.*y.*cosd(omega)));
tau(i+1,j+1) = (1/2)*(-pz/hG)*Gamma(i+1,j+1);
j =j+1;
y= y+d2;
end
y = 0; %-a
j = 0;
x= x+d;
i= i+1;
end
1 Comment
Daniel Shub
on 5 Apr 2013
Your code runs fine for me ...
Answers (3)
Modern Matlab versions are case-sensitive. Then perhaps Gamma is partially confused with gamma(). Perhaps it helps, when you define the variable Gamma before using it:
Gamma = [];
But a pre-allocation would be better.
Dirk
on 5 Apr 2013
0 votes
Categories
Find more on Gamma Functions in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!