Use value app designer in script.m

hi, i want to use CurrenList value (in app Designal) to use in myscript .m
How can i do it?

 採用された回答

Rik
Rik 2023 年 6 月 5 日
編集済み: Rik 2023 年 6 月 5 日

0 投票

The solution is simple: use a function instead of a script (although it is possible to write a script that will use this value).

A script shares the workspace with the calling environment, while a function uses input and output arguments. That makes functions a documentable interface that can be updated without worrying that code using the function will break.

You should not use a script for things you plan to use after next week.

If you have trouble with Matlab basics you may consider doing the Onramp tutorial (which is provided for free by Mathworks). There is a chapter on functions.

7 件のコメント

shamal
shamal 2023 年 6 月 10 日
Can you give me an example to do it? With an example everything would be clearer
Rik
Rik 2023 年 6 月 10 日
An example of what exactly? Of how to create a function? Or how to call your function in a GUI?
Did you do the tutorial? That should explain most of your questions far better than I could do in a comment.
shamal
shamal 2023 年 6 月 10 日
編集済み: shamal 2023 年 6 月 10 日
in the example posted before I would like to print the CurrenList value variable on the Command window
>>
Rik
Rik 2023 年 6 月 11 日
You probably want disp. If that doesn't do exactly what you want, you will need fprintf, which provides full control over the formatting. Since you didn't share the actual data, I can't tailor the examples in the documentation to your case.
shamal
shamal 2023 年 6 月 11 日
編集済み: shamal 2023 年 6 月 11 日
i share actual code.(this is app designer)
i want to see name value .,. how do i code function to do it?
Rik
Rik 2023 年 6 月 11 日
You can use either this:
disp(name)
or this:
fprintf('the value of the ''name'' variable is %s\n',name)
But since you're using a graphical user interface, it makes more sense to show this value somewhere in your GUI, since a user might not be looking at the command window.
shamal
shamal 2023 年 6 月 11 日
thank you

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeDevelop Apps Using App Designer についてさらに検索

質問済み:

2023 年 6 月 2 日

コメント済み:

2023 年 6 月 11 日

Community Treasure Hunt

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

Start Hunting!

Translated by