Do I have to import an array into function workspace?

2 ビュー (過去 30 日間)
laboratoryassist
laboratoryassist 2017 年 10 月 5 日
コメント済み: laboratoryassist 2017 年 10 月 6 日
Hello,
i want to use a function that refers to an Array ("Auswahl") in the base Workspace. The code is
function choice = Parameterwahl
d=dialog('Position',[500 400 300 150],'Name','');
txt = uicontrol('Parent',d,'Style','text','Position',[-52 80 400 40],...
'String','Choose color','FontSize',12);
popup = uicontrol('Parent',d,'Style','popup','Position',[75 70 150 25],...
'String', *Auswahl*,'Callback',@popup_callback);
btn = uicontrol('Parent',d,'Position',[89 20 70 25],'String','Ok',...
'Callback','delete(gcf)');
uiwait(d);
function popup_callback(popup,callbackdata)
idx = popup.Value;
popup_items = popup.String;
choice = char(popup_items(idx,:));
end
end
In the main script I call the function with "Parameterwahl" and Matlab seems to have a Problem with getting the Content of the Array "Auswahl" - the dropdownbox doesnt Show up, which does the Dialog is run in the main script. Do I have to Import the Array into the Workspace of the Parameterwahl.m-file ?
Thanks in advance.

採用された回答

Niels
Niels 2017 年 10 月 5 日
Hi laboratoryassist,
every function got its own workspace and it is also different from the "base" workspace that you can see when using the command line.
but it is still possible to get access to the base workspace, a similar question has been asked and answered.
This might help you.
  1 件のコメント
laboratoryassist
laboratoryassist 2017 年 10 月 6 日
Hello Niels,
thanks for the advide!

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

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by