Matlab floating point problem

3 ビュー (過去 30 日間)
KK
KK 2018 年 12 月 10 日
編集済み: per isakson 2018 年 12 月 10 日
Hello. I am using Matlab R2007b. I have a floating point problem in it. I am using x=rotx(45*pi/180)*[1 2 3]' and its value is x =[1.0000; 3.5355; 0.7071]. And i am doing reverse rotation of x which is y=rotx(-45*pi/180)*x. And i am doing y==[1; 2; 3]. Logically it is showing 1 1 0. I want all 1's when y==[1; 2; 3]. Can any one help with this problem.

回答 (1 件)

per isakson
per isakson 2018 年 12 月 10 日
編集済み: per isakson 2018 年 12 月 10 日
The script
%%
x = rotx(45*pi/180)*[1 2 3]';
y = rotx(-45*pi/180)*x;
is1 = abs((y-[1;2;3])<eps(10))
returns
is1 =
1
1
1
with R2018b

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by