problem with defining variable

7 vues (au cours des 30 derniers jours)
Dirk
Dirk le 5 Avr 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
  1 commentaire
Daniel Shub
Daniel Shub le 5 Avr 2013
Your code runs fine for me ...

Connectez-vous pour commenter.

Réponses (3)

Jan
Jan le 5 Avr 2013
Modifié(e) : Jan le 5 Avr 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 le 5 Avr 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 commentaire
Jan
Jan le 5 Avr 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.

Connectez-vous pour commenter.


Dirk
Dirk le 5 Avr 2013
I forgot this at the second loop: x= 0; y= 0; i = 0; j = 0;

Catégories

En savoir plus sur Gamma Functions dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by