Use value app designer in script.m

1 Ansicht (letzte 30 Tage)
Luca Re
Luca Re am 2 Jun. 2023
Kommentiert: Luca Re am 11 Jun. 2023
hi, i want to use CurrenList value (in app Designal) to use in myscript .m
How can i do it?

Akzeptierte Antwort

Rik
Rik am 5 Jun. 2023
Bearbeitet: Rik am 5 Jun. 2023

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 Kommentare
Rik
Rik am 11 Jun. 2023
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.
Luca Re
Luca Re am 11 Jun. 2023
thank you

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

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!

Translated by