I am getting a strange error on the array operation. Please help.

s = size(n3);
for l1 = 1:s(1)
m(l1,1) = (n3(l1,1))^(2.6666667);
end
This is a simple loop. In this, I am trying to calculate the n3^2.6666667. But, I am getting a complex number output. Variable n3 varies between -0.7 to 0.7. So, there is no chance of getting a complex value. I checked with the individual values like -0.7^2.6666667 so on. What is the error? I couldn't understand. Kindly help in this.

 Respuesta aceptada

KSSV
KSSV el 29 de Dic. de 2017
Editada: KSSV el 29 de Dic. de 2017
-0.7^2.6666667 this check is not correct.....you should check for (-0.7)^2.6666667. Note that roots of negative numbers can be complex. I don't think this is any strange.

Más respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Centro de ayuda y File Exchange.

Preguntada:

el 29 de Dic. de 2017

Editada:

el 29 de Dic. de 2017

Community Treasure Hunt

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

Start Hunting!

Translated by