[App Designer]how to make endless loop program.

I want to create an app that continuously receives input and displays new images.
If I simply put a function that creates an image like below,
while(flag)
function make_image()
end
the program seems to freeze. How should I design it?

5 件のコメント

Voss
Voss 2021 年 12 月 21 日
Make sure there's a drawnow() being called somewhere within the loop.
while(flag)
make_image();
drawnow();
end
Geoff Hayes
Geoff Hayes 2021 年 12 月 21 日
@Jae-Hee Park - why is a while loop needed? When the new data is received, draw the image then. The problem with the while loop is that your code will become "stuck" within it and no other action (GUI button press, callback, etc.) will be called unless you make the loop interruptible by introducing a pause or the drawnow like @Benjamin suggests.
Jae-Hee Park
Jae-Hee Park 2021 年 12 月 22 日
@Geoff Hayes I want to make app which makes time varying star image. My plan is that app looks like the obserber is moving.
Thus I think Input some boresight sequence then app make images.
Geoff Hayes
Geoff Hayes 2021 年 12 月 22 日
@Jae-Hee Park - consider using a timer to periodically update your image. The timer could have a period of one second (or less) and within its callback, you would make the update (similar to the body of your while loop).
Jae-Hee Park
Jae-Hee Park 2021 年 12 月 23 日
@Geoff Hayes Thank you!

サインインしてコメントする。

 採用された回答

Jae-Hee Park
Jae-Hee Park 2021 年 12 月 23 日

0 投票

Geoff Hayes 2021년 12월 21일 13:12
@Jae-Hee Park - why is a while loop needed? When the new data is received, draw the image then. The problem with the while loop is that your code will become "stuck" within it and no other action (GUI button press, callback, etc.) will be called unless you make the loop interruptible by introducing a pause or the drawnow like @Benjamin suggests.

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

質問済み:

2021 年 12 月 21 日

回答済み:

2021 年 12 月 23 日

Community Treasure Hunt

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

Start Hunting!

Translated by