Filter löschen
Filter löschen

How can I pass variable from GUI to matlab workspace?

13 Ansichten (letzte 30 Tage)
Tomislav
Tomislav am 4 Nov. 2012
Bearbeitet: Stephen23 am 24 Dez. 2021
The global function is nice, for example:
(in GUI):
global y
y=5;
and then in matlab command window i type global y and it is done.
The way I want to do it is that y is automatticaly printed in workspace without me typing global y in command window. Can it be done?
Thanks.
  5 Kommentare
Nafiz Farhan
Nafiz Farhan am 7 Feb. 2018
In this link, could you please point a little bit more, where should I look at, because this is a long article and I still cannot find a way to pass GUI input data to workspace.
Jan
Jan am 7 Feb. 2018
@Nafiz: I do never create variables remotely in another workspace. I consider this as too confusing and prone to bugs. But if you have a really good reason to do this, it is easy:
assignin('base', 'V', data)
Now the variable V is created in the base workspace (accessible in the command window) and set to the value data.
The linked article concerns another problem: Sharing data between callbacks. Then using the base workspace is a bad idea, because it is much better to store the data inside the figure, in the UserData or ApplicationData, e.g. using setappdata or guidata.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Azzi Abdelmalek
Azzi Abdelmalek am 4 Nov. 2012
Bearbeitet: Azzi Abdelmalek am 4 Nov. 2012
don't use semicolon ;
y=5
  8 Kommentare
Tomislav
Tomislav am 4 Nov. 2012
That is if I want automatically put variable in editbox witch I can do manually it is important that this variable is shown in main matlab workspace.
Masoud
Masoud am 18 Jul. 2015
Bearbeitet: Masoud am 18 Jul. 2015
Thank you
That was really helpful
good luck
Mehrabi

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Variables 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