problem with defining variable

8 Ansichten (letzte 30 Tage)
Dirk
Dirk am 5 Apr. 2013
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

Antworten (3)

Jan
Jan am 5 Apr. 2013
Bearbeitet: Jan am 5 Apr. 2013
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 am 5 Apr. 2013
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 Kommentar
Jan
Jan am 5 Apr. 2013
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.

Melden Sie sich an, um zu kommentieren.


Dirk
Dirk am 5 Apr. 2013
I forgot this at the second loop: x= 0; y= 0; i = 0; j = 0;

Kategorien

Mehr zu Gamma Functions finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by