フィルターのクリア

how to save variable from class of GUI to workspace?

1 回表示 (過去 30 日間)
sandy
sandy 2014 年 6 月 6 日
コメント済み: Ben11 2014 年 6 月 17 日
below here is in GUI,where dial() is a class which i used for created a knob in GUI,i need to save Value in dial() class to workspace ,and when i change the knob in GUI,variable VALUE will change,that should be updated to workspace variable.i need help here
snap = dial('refVal',0,...
'refOrientation',255*pi/180,...
'valRangePerRotation',5, ...
'Min',1, ...
'Max',4,...
'Value',1,...
'doSnap',1,...
'Position',thisPos,...
'dialRadius',0.35,...
'tickRadius',0.45,...
'tickLabelRadius',0.45,...
'HorizontalAlignment','left',...
'Tag','snapDial', ...
'tickVals', [1 2 3 4],...
'tickStrs',{'one' 'two' 'three' 'four'});

回答 (2 件)

Image Analyst
Image Analyst 2014 年 6 月 9 日

Ben11
Ben11 2014 年 6 月 6 日
編集済み: Ben11 2014 年 6 月 6 日
Maybe you could use setappdata(...) in your GUI to store dial() and then use getappdata(...) to retrieve it in the workspace? I have never used it with classes but it could work.
For example, in your GUI you could write:
setappdata(0,'Name of your variable',variable); %where variable would be dial() and the name is arbitrary.
% Update handles structure;
guidata(hObject,handles);
Then in the workspace:
VariableInWorkspace = getappdata(0,'Name of your variable');%where 'Name of your variable' is the same as that using setappdata in the GUI.
  3 件のコメント
Ben11
Ben11 2014 年 6 月 9 日
You can put setappdata in the opening function of your GUI as well and also at the beginning of your function callbacks if you need to use information from dial() in them.
You can use the line (VariableInWorkspace = getappdata(0,...)) I wrote in the above answer directly in the workspace and it should work. If you call external scripts you would also need to write getappdata() at the beginning and setappdata() at the end to update your variables.
Ben11
Ben11 2014 年 6 月 17 日
So...did it work?

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

カテゴリ

Help Center および File ExchangeProgramming についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by