How to write and run while loop in app design?
조회 수: 4 (최근 30일)
이전 댓글 표시
C= app.CollectionEditField.Value;
S= app.ServingEditField.Value;
app.cycle=0;
cycle_t=app.cycle;
app.FC=0;
F_C=app.FC;
app.F=0;
F_1 =app.F;
SC= S;
while F_C<=double(SC-0.000001))
F_1= double(S*C);
S= double(S-F_1);
F_C= double(F_C+F_1);
Fo= F_C;
cycle_o= (cycle_t+1);
end
app.CycleEditField.Value= cycle_o;
app.FInalCollectionEditField.Value= Fo;
댓글 수: 8
dpb
2021년 6월 14일
F_C=0;
cycle_t=0;
S=15;
C=0.02;
SC=S;
while F_C <=SC-0.000001
F_1= S*C;
S= S-F_1;
F_C= F_C+F_1;
Fo= F_C;
cycle_o=cycle_t+1;
end
>> cycle_o
cycle_o =
1
>> F_C
F_C =
15.0000
>> SC
SC =
15
>>
I have no klew what you're trying to do here, but your first line in the while construct sets F_1 to the S*C product and then the control variable F_C is set to F_C+F_1 which is F_1 since F_C is initialized to zero. Thus, the inequality
F_C <= SC-eps
fails and the loop terminates.
답변 (1개)
Shadaab Siddiqie
2021년 6월 15일
From my understanding you are not able to run while loop in your code. I dont see anything wrong with the loop or with the code that you mentioned in the comment, I would advice you to check if the varaibles
C= app.CollectionEditField.Value;
S= app.ServingEditField.Value;
are as expected.
참고 항목
카테고리
Help Center 및 File Exchange에서 Develop Apps Using App Designer에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!