フィルターのクリア

I want to use atan2 in my equation. When I use atan2 , I get answer NaN. But when I use 'atan' , i didn't get NaN. Why?

5 ビュー (過去 30 日間)
clear all
clc
syms alpha1 alpha1_d alpha1_dd
a=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_dd
a=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 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=double(subs(l1_dd,[alpha1,alpha1_d,alpha1_dd],[0.5236,0.2,0.01]));
% Ans L_dd=-0.1789

採用された回答

Swatantra Mahato
Swatantra Mahato 2021 年 2 月 19 日
編集済み: Swatantra Mahato 2021 年 2 月 19 日
Hi Vishal,
You can try with "atan2" after making the following modifications
syms alpha1 alpha1_d alpha1_dd real
and add the line
l1=rewrite(l1,'sqrt');
before the line
l1_d=diff(l1,alpha1)*alpha1_d;
I have brought the issue to the notice of our developers. They will investigate the matter futher
Hope this helps
  3 件のコメント
Paul
Paul 2021 年 2 月 21 日
Seemed to work for me:
>> syms alpha1 alpha1_d alpha1_dd real
a=3;
b=2;
th1=atan2(a*sin(alpha1),(b*cos(alpha1)));
l1=a*cos(alpha1)*sin(th1)-b*sin(alpha1)*cos(th1);
l1 = rewrite(l1,'sqrt');
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]);
vpa(L_dd)
ans =
-0.17888259249992260757966824848436
Vishal Naik
Vishal Naik 2021 年 2 月 22 日
It works. Thank you....

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeConversion Between Symbolic and Numeric についてさらに検索

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by