Effacer les filtres
Effacer les filtres

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

1 vue (au cours des 30 derniers jours)
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);

Réponse acceptée

Sulaymon Eshkabilov
Sulaymon Eshkabilov le 25 Mai 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);

Plus de réponses (0)

Catégories

En savoir plus sur Characters and Strings dans Help Center et File Exchange

Tags

Produits


Version

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by