MATLAB: How to fix the error ”Conversion to function_handle from double is not possible.” for the below matlab code

Gms =1.3271244e20;
x1 = -142253701000; % km change into (m)
y2 = -37809925000;
x=[x1 y2];
v1= 7.652055*1000;
v2= -29.283807*1000;
v=[v1 v2];
T=365*24*60*60;
xe= sqrt(x1^2+y2^2);
time=0;
A = @(x) -Gms*x1/norm(x)^3;
A=0;
dt=2000
timeplot=[0;100000;3]

Best Answer

Use .* ./ and .^ when you have function handle
A = @(x) -Gms.*x1./norm(x).^3; %change this line