`clear all clc syms alpha1 alpha1_d alpha1_dda=3;b=2;th1=atan2(a*sin(alpha1),(b*cos(alpha1)));l1=a*cos(alpha1)*sin(th1)-b*sin(alpha1)*cos(th1);l1_d=diff(l1,alpha1)*alpha1_d; % fisrt derivative of l1`

l1_dd=jacobian(l1_d,[alpha1,alpha1_d])*[alpha1_d;alpha1_dd];% Sencond derivative of l1

% subs alpha1=0.5236, alpha1_d=0.2, alpha1_dd=0.01

L_dd=subs(l1_dd,[alpha1,alpha1_d,alpha1_dd],[0.5236,0.2,0.01]);% Ans L_dd=NaN

%%%% when I replace atan2 by atan

clear all clc syms alpha1 alpha1_d alpha1_dda=3;b=2;th1=atan(a*sin(alpha1)/(b*cos(alpha1)));l1=a*cos(alpha1)*sin(th1)-b*sin(alpha1)*cos(th1);l1_d=diff(l1,alpha1)*alpha1_d;% fisrt derivative of l1l1_dd=jacobian(l1_d,[alpha1,alpha1_d])*[alpha1_d;alpha1_dd];% Sencond derivative of l1% subs alpha1=0.5236, alpha1_d=0.2, alpha1_dd=0.01L_dd=double(subs(l1_dd,[alpha1,alpha1_d,alpha1_dd],[0.5236,0.2,0.01]));% Ans L_dd=-0.1789

# MATLAB: I want to use atan2 in the equation. When I use atan2 , I get answer NaN. But when I use ‘atan’ , i didn’t get NaN. Why

atan vs atan2mathematicsMATLAB

## Best Answer