フィルターのクリア

My program won't stop running and I cannot figure out why.

2 ビュー (過去 30 日間)
Morgan Tippett
Morgan Tippett 2018 年 2 月 27 日
回答済み: Walter Roberson 2018 年 2 月 27 日
frac=0.525;
b=7;
A=[frac*b];
F=[floor(frac*b)];
frac=A(1)-F(1);
while frac-floor(frac)~=0
A=horzcat(A,frac*b);
for i=1:length(A)-1
if abs(A(i)-A(length(A)))<10^(-5)
sprintf('This is a repeating fraction in base %d',b)
break
end
end
F=horzcat(F,floor(frac*b));
frac=A(length(A))-F(length(F));
end
A
F

回答 (1 件)

Walter Roberson
Walter Roberson 2018 年 2 月 27 日
break only breaks one level. It would leave the for but not the while at the same time.

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by