Please debug this code for me...
1 次查看(过去 30 天)
显示 更早的评论
alpha=10;
D1B2B3=18.3;
B3B2B1=41.34;
B1B2P1=16.13;
B1B3=2767;
B1B2=1612;
F8=64172;
F6=-68189;
F7=21073;
F9=(F8*B1B2*sind(D1B2B3+B3B2B1)+F6*B1B3*sind(alpha)-F7*B1B3*cosd(alpha))/B1B2*sind(B1B2P1);
zero=F8*B1B2*sind(D1B2B3+B3B2B1)+F6*B1B3*sind(alpha)-F7*B1B3*cosd(alpha)-F9*B1B2*sind(B1B2P1)
Its a part of a long program I've written and after lot of debugging, I realised that this is the fault. I've found the value of F9 using a particular equation, and when I substitute it back in the same equation, it doesn't give me zero! I've tried it in C++ too but still no zero. Can someone tell me why? Is it precision error, or have I made some silly error?
0 个评论
采纳的回答
Andrei Bobrov
2012-6-25
Try
F9=(F8*B1B2*sind(D1B2B3+B3B2B1)+F6*B1B3*sind(alpha)-F7*B1B3*cosd(alpha))/B1B2*sind(B1B2P1)
zero=F8*B1B2*sind(D1B2B3+B3B2B1)+F6*B1B3*sind(alpha)-F7*B1B3*cosd(alpha)-F9*B1B2/sind(B1B2P1)
or
F9=(F8*B1B2*sind(D1B2B3+B3B2B1)+F6*B1B3*sind(alpha)-F7*B1B3*cosd(alpha))/(B1B2*sind(B1B2P1))
zero=F8*B1B2*sind(D1B2B3+B3B2B1)+F6*B1B3*sind(alpha)-F7*B1B3*cosd(alpha)-F9*B1B2*sind(B1B2P1)
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!