Why am I getting the error "Array indices must be positive integers or logical values."?

1 visualización (últimos 30 días)
clear all;clc;
x=1;y=2
a=0.25
k=2;n=5;
u=real(complex(k,n)+sqrt(complex(k,n).^2-4.*a.^2))
v=imag(complex(k,n)+sqrt(complex(k,n).^2-4.*a.^2))
kfinal=(x.*(u.*x-v.*y)-y(u.*y+v.*x))./(x.^2+y.^2)+a.^2.*(x.*(u.*x-v.*y)+y(u.*y+v.*x))./((u.*x-v.*y).^2+(u.*y+v.*x).^2);
nfinal=(x.*(u.*y+v.*x)+y(u.*x-v.*y))./(x.^2+y.^2)+a.^2.*(x.*(u.*x+v.*y)-y(u.*x+v.*y))./((u.*x-v.*y).^2+(u.*y+v.*x).^2);
Error :
Array indices must be positive integers or logical values.
Error in deneme (line 9)
kfinal=(x.*(u.*x-v.*y)-y(u.*y+v.*x))./(x.^2+y.^2)+a.^2.*(x.*(u.*x-v.*y)+y(u.*y+v.*x))./((u.*x-v.*y).^2+(u.*y+v.*x).^2);

Respuesta aceptada

Sulaymon Eshkabilov
Sulaymon Eshkabilov el 25 de Mayo de 2021
Hi,
You have overlooked .* after y:
kfinal=(x.*(u.*x-v.*y)-y.*(u.*y+v.*x))./(x.^2+y.^2)+a.^2.*(x.*(u.*x-v.*y)+y.*(u.*y+v.*x))./((u.*x-v.*y).^2+(u.*y+v.*x).^2);
nfinal=(x.*(u.*y+v.*x)+y.*(u.*x-v.*y))./(x.^2+y.^2)+a.^2.*(x.*(u.*x+v.*y)-y.*(u.*x+v.*y))./((u.*x-v.*y).^2+(u.*y+v.*x).^2);

Más respuestas (0)

Categorías

Más información sobre Characters and Strings en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by