Open and control the same .m file from current .m file

3 ビュー (過去 30 日間)
Duc Phan
Duc Phan 2022 年 5 月 4 日
回答済み: BhaTTa 2025 年 3 月 13 日
Basically I created a UI interface in a .m file. I need to open the same instance of the UI from the original UI and control its function but whenever I do that I dont see anything new variables or objects in my current workspace.

回答 (1 件)

BhaTTa
BhaTTa 2025 年 3 月 13 日
Hey @Duc Phan.When you create a UI in MATLAB using a .m file (often referred to as a programmatic UI), it typically runs in its own scope or workspace. This means that the variables and objects created within the UI are not directly accessible from the base workspace or from other functions unless explicitly returned or passed.
If you want to control a UI from another UI or script, you can achieve this by maintaining references to the UI objects and using callbacks or shared data structures. Here's how you can manage this:
1. Use appdesigner:
  • If possible, consider using App Designer to create your UI. It automatically manages instances and provides a more structured way to handle UI interactions.
2. You can make use of persistent object and use it as reference for the other UI
Hope it helps.

カテゴリ

Help Center および File ExchangeGet Started with MATLAB についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by