필터 지우기
필터 지우기

How can I pass variable from GUI to matlab workspace?

조회 수: 13 (최근 30일)
Tomislav
Tomislav 2012년 11월 4일
편집: Stephen23 2021년 12월 24일
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
Nafiz Farhan
Nafiz Farhan 2018년 2월 7일
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 2018년 2월 7일
@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.

댓글을 달려면 로그인하십시오.

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2012년 11월 4일
편집: Azzi Abdelmalek 2012년 11월 4일
don't use semicolon ;
y=5
  댓글 수: 8
Tomislav
Tomislav 2012년 11월 4일
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 2015년 7월 18일
편집: Masoud 2015년 7월 18일
Thank you
That was really helpful
good luck
Mehrabi

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Variables에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by