For loop indexing error
Información
La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.
Mostrar comentarios más antiguos
ri = 40.34;
rf = 40;
Em = 3.5e-9;
Ef = 1000e-9;
z = linspace(0,0.34,12);
n=1;
E = zeros(12);
r = zeros(12);
for j = 1:12
r(j)= z(j)+40;
E(j) = Em*(ri/r(j))+(((ri-r(j))/(ri-rf))^(n/2))*(Ef-Em(ri/rf));
end
I'm getting this error
Array indices must be positive
integers or logical values.
Error in interface_modulus
(line 11)
E(j) =
Em*(ri/r(j))+(((ri-r(j))/(ri-rf))^(n/2))*(Ef-Em(ri/rf));
Respuestas (1)
ri = 40.34;
rf = 40;
Em = 3.5e-9;
Ef = 1000e-9;
z = linspace(0,0.34,12);
n=1;
E = zeros(12);
r = zeros(12);
for j = 1:12
r(j)= z(j)+40;
E(j) = Em*(ri/r(j))+(((ri-r(j))/(ri-rf))^(n/2))*(Ef-Em*(ri/rf));
end
Type error:
Replaced
Em(ri/rf)
with
Em*(ri/rf)
When you try Em(ri/rf), it will take as index..and the value comes to be fraction. The indices cannot be fraction..so error.
La pregunta está cerrada.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!