For loop in matlab
Mostrar comentarios más antiguos
I write a code about a fission process and i want to repeat this 10^6 times i can use for loop right? But i get an error like this: Conversion to logical from sym is not possible.
What is the problem? Can you help me?
Error in Untitled58 (line 34)
if d1<ds
n=10^6;
for i=1:n
R=0.30; %in mm
l=0.1; %in mm
d=0.05; %in mm
x1=rand;
x2=rand;
x3=rand;
x4=rand;
x5=rand;
ksi1=x1;
ksi2=x2;
ksi3=x3;
ksi4=x4;
ksi5=x5;
r=(x1)^1/3* R;
mu=2*x2-1;
fi=2*pi*x3;
ds1=-r*mu+((r^2*mu^2)+(R^2-r^2))^1/2;
ds2=-r*mu-(r^2*mu^2+R^2-r^2)^1/2;
if ds1>0
ds=ds1;
else
ds=ds2;
end
syms s;
syms d1;
s=d1; %d*=d1
if x4<0.3
d=d1;
elseif x4>0.3
d1=(-l*log(exp(x5)));
end
if d1<ds
disp('fission product is not reached to surface of sphere');
else
disp('fission product is reached to surface of sphere');
end
end
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Direct Search en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!