Why am I getting the error "Array indices must be positive integers or logical values."?
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
onur karakurt
il 25 Mag 2021
Risposto: Sulaymon Eshkabilov
il 25 Mag 2021
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);
0 Commenti
Risposta accettata
Sulaymon Eshkabilov
il 25 Mag 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);
0 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Matrix Indexing in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!