Run code with two sections - app designer
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Shahar ben ezra
am 13 Jul. 2021
Kommentiert: Debt
am 16 Jul. 2021
I made an example of a problem I have.
I wrote a code with 2 sections
When I press RUN_1 it calculates X * Y (this is works)
When I press RUN_2 he does not remember the value XY so he does not compute me XYZ (this is not works :( )
Thanks!
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/683643/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/683648/image.png)
1 Kommentar
Akzeptierte Antwort
Cris LaPierre
am 13 Jul. 2021
Bearbeitet: Cris LaPierre
am 14 Jul. 2021
You need to keep in mind variable scope. All your callbacks are functions. Variables created inside a function are lost once the function terminates. The way around this in app designer is to create an app property to capture these values. You can then access them using the app.varName syntax.
3 Kommentare
Cris LaPierre
am 15 Jul. 2021
You are not creating a function. You are creating a propery. There is no need to change the name. Use XY. The only change is, instead of using XY, you would now use app.XY.
You can see an example here: https://www.mathworks.com/help/matlab/creating_guis/share-data-across-callbacks-in-app-designer.html
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Develop Apps Using App Designer finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!