problem with defining variable

조회 수: 7 (최근 30일)
Dirk
Dirk 2013년 4월 5일
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
Daniel Shub
Daniel Shub 2013년 4월 5일
Your code runs fine for me ...

댓글을 달려면 로그인하십시오.

답변 (3개)

Jan
Jan 2013년 4월 5일
편집: Jan 2013년 4월 5일
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
Dirk 2013년 4월 5일
Thanks, but its seems a problem with the variable and I dont know why...:(
variable names: G,T,X,Q
only G and T works
  댓글 수: 1
Jan
Jan 2013년 4월 5일
Please post only answers in the answers section. This might be a comment to my answer. I cannot read anything on your screen shot. A copy&pasted text would be much easier to read.

댓글을 달려면 로그인하십시오.


Dirk
Dirk 2013년 4월 5일
I forgot this at the second loop: x= 0; y= 0; i = 0; j = 0;

카테고리

Help CenterFile Exchange에서 Gamma Functions에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by