strange operation .^ result came out

1 visualización (últimos 30 días)
NoYeah
NoYeah el 8 de Abr. de 2020
Comentada: NoYeah el 8 de Abr. de 2020
I was trying to power operation for constant
t=linspace(0,10,100);
y=(-1)^(t);
I expected the results as 1 1 1 1 -1 -1 -1 1 -1 1 -1 1 1 -1 something like the combination of 1 and -1
but the result is not what i have expected
below is the following results
Columns 1 through 7
0.0000 + 0.0000i 0.0958 + 0.0315i 0.1616 + 0.1190i 0.1731 + 0.2431i 0.1167 + 0.3754i -0.0077 + 0.4838i -0.1863 + 0.5383i
Columns 8 through 14
-0.3934 + 0.5169i -0.5955 + 0.4100i -0.7570 + 0.2223i -0.8465 - 0.0269i -0.8421 - 0.3065i -0.7360 - 0.5788i -0.5356 - 0.8051i
Columns 15 through 21
-0.2632 - 0.9520i 0.0475 - 0.9973i 0.3565 - 0.9332i 0.6238 - 0.7678i 0.8156 - 0.5242i 0.9098 - 0.2361i 0.8989 + 0.0571i
Columns 22 through 28
0.7913 + 0.3168i 0.6092 + 0.5112i 0.3849 + 0.6203i 0.1550 + 0.6389i -0.0458 + 0.5762i -0.1904 + 0.4546i -0.2636 + 0.3042i
Columns 29 through 35
-0.2644 + 0.1583i -0.2055 + 0.0464i -0.1106 - 0.0106i -0.0094 - 0.0041i 0.0675 + 0.0604i 0.0953 + 0.1650i 0.0591 + 0.2825i
Columns 36 through 42
-0.0425 + 0.3813i -0.1973 + 0.4319i -0.3807 + 0.4122i -0.5608 + 0.3120i -0.7029 + 0.1355i -0.7763 - 0.0991i -0.7597 - 0.3616i
Columns 43 through 49
-0.6453 - 0.6153i -0.4405 - 0.8221i -0.1675 - 0.9497i 0.1403 - 0.9761i 0.4431 - 0.8940i 0.7010 - 0.7123i 0.8806 - 0.4540i
Columns 50 through 56
0.9598 - 0.1536i 0.9315 + 0.1491i 0.8045 + 0.4148i 0.6016 + 0.6112i 0.3559 + 0.7181i 0.1049 + 0.7295i -0.1155 + 0.6550i
Columns 57 through 63
-0.2769 + 0.5169i -0.3631 + 0.3462i -0.3720 + 0.1771i -0.3154 + 0.0403i -0.2168 - 0.0418i -0.1060 - 0.0590i -0.0139 - 0.0151i
Columns 64 through 70
0.0334 + 0.0731i 0.0200 + 0.1794i -0.0571 + 0.2728i -0.1871 + 0.3240i -0.3471 + 0.3106i -0.5063 + 0.2216i -0.6310 + 0.0603i
Columns 71 through 77
-0.6912 - 0.1561i -0.6659 - 0.3987i -0.5473 - 0.6316i -0.3426 - 0.8180i -0.0736 - 0.9260i 0.2267 - 0.9344i 0.5190 - 0.8364i
Columns 78 through 84
0.7638 - 0.6409i 0.9281 - 0.3715i 0.9901 - 0.0629i 0.9432 + 0.2447i 0.7964 + 0.5118i 0.5735 + 0.7059i 0.3079 + 0.8061i
Columns 85 through 91
0.0384 + 0.8066i -0.1982 + 0.7170i -0.3726 + 0.5601i -0.4675 + 0.3676i -0.4798 + 0.1746i -0.4211 + 0.0134i -0.3144 - 0.0923i
Columns 92 through 98
-0.1901 - 0.1309i -0.0796 - 0.1046i -0.0101 - 0.0291i 0.0011 + 0.0701i -0.0506 + 0.1627i -0.1559 + 0.2190i -0.2936 + 0.2162i
Columns 99 through 100
-0.4338 + 0.1425i -0.5440 + 0.0000i
and blow is its figure
i don`t know why this operation bring my numbers to complex plane
why this happens?
I just want to do power operation for each value in t array

Respuesta aceptada

James Tursa
James Tursa el 8 de Abr. de 2020
Editada: James Tursa el 8 de Abr. de 2020
You are raising -1 to a fractional exponent, so complex numbers will result.
Did you mean something like this instead
t = 0:100;
y = (-1).^t;

Más respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by