Why am I getting the error "Array indices must be positive integers or logical values."?
1 view (last 30 days)
Show older comments
onur karakurt
on 25 May 2021
Answered: Sulaymon Eshkabilov
on 25 May 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 Comments
Accepted Answer
Sulaymon Eshkabilov
on 25 May 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 Comments
More Answers (0)
See Also
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!