循环累加过程中,为什么得不到想要的值。

clear all
c=0;
for n=1:361
if c==2*pi
disp('qqq')
else
disp('qq')
c=c+pi/180;
end
为什么显示不了qqq呀

 採用された回答

fiwakit
fiwakit 2022 年 11 月 22 日

0 投票

楼上说的是对的,你把他限定在一个小的范围内就可以了,比如:
clear all
c=0;
for n=1:361
if abs(c-2*pi)<=1e-6
disp('qqq')
else
disp('qq')
c=c+pi/180;
end
end

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File Exchange二维图和三维图 についてさらに検索

タグ

質問済み:

2022 年 11 月 22 日

回答済み:

2022 年 11 月 22 日

Community Treasure Hunt

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

Start Hunting!