フィルターのクリア

How to increment variable with Push button Dashboard ?

43 ビュー (過去 30 日間)
Cédric DEPOILLY
Cédric DEPOILLY 2024 年 6 月 26 日 17:02
回答済み: Avni Agrawal 2024 年 6 月 27 日 8:45
I want to increment the block "variable" of 1 when I push on the button.
Thanks

回答 (2 件)

Dheeraj
Dheeraj 2024 年 6 月 27 日 5:25
Hi Cédric DEPOILLY,
I understand you want to increment a variable in a block when ever the button is pushed.
Unfortunately, the "Push Button" block changes variables into a constant scalar and does not accept variable changes in response to clicks. Instead, you could use the "Callback Button" block. The Callback Button block executes MATLAB code in response to a click or press of the button. You can update the block parameters to suit your needs and use this block to increment the variable whenever it is clicked.
To know more about the "CallBack Button" customisation you could refer to the below MATLAB's documentation.

Avni Agrawal
Avni Agrawal 2024 年 6 月 27 日 8:45
I understand that you are trying to increase a variable everytime button is clicked. You can accomplish this using Data Memory and an Add block. The logic would work as follows: if the button is pressed, add 0; otherwise, add 1. The schematic representation of this logic is depicted in the attachment.
I hope this helps.

カテゴリ

Help Center および File ExchangeControl Simulations with Interactive Displays についてさらに検索

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by