MATLAB Answers

How to write and run while loop in app design?

조회 수: 3(최근 30일)
Shabaz Khan
Shabaz Khan 2021년 6월 11일
댓글: Shabaz Khan 2021년 6월 17일
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
Shabaz Khan
Shabaz Khan 2021년 6월 14일
Try this in command window. You will see cycle number is showing 860.
FC=0;
C=0.02;
cycle=0;
>> S=35;
>> SC=S;
F=0;
while FC <=SC-0.000001
F= S*C;
S= S-F;
FC= FC+F;
cycle=cycle+1;
end

댓글을 달려면 로그인하십시오.

답변(1개)

Shadaab Siddiqie
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.
  댓글 수: 1
Shabaz Khan
Shabaz Khan 2021년 6월 17일
As I am trying to design the app so, my intension is to apply C and S value using app numerical box. When I will give this value in the box then they will do the calculation using the while loop. And after finishing the the calculation it will show the result in another box. Can you kindly say me, what exactly I have to do for design such app? I am getting the result from the command window but when I am using in app its not working?

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

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

Start Hunting!

Translated by