how to return the value to workspace after user select item in pop-up menu

조회 수: 1 (최근 30일)
hi, i want to return the value to workspace, when i select the specific item in pop-up menu, how to store it in the workspace.
  댓글 수: 3
wenchao zhang
wenchao zhang 2024년 5월 25일
편집: wenchao zhang 2024년 5월 25일
hi,stephen,define the output argument in the main function or in the callback function? about waitfor, i have a check, yes it can stop the following command in a script untill current event finished
Stephen23
Stephen23 2024년 5월 26일
define the output argument in the main function or in the callback function?"
From the main function.

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

채택된 답변

Animesh
Animesh 2024년 5월 25일
You can use the assignin function in MATLAB to save the selected value to the workspace.
Here's how you can do it:
assignin('base', 'selection', str{val});
With this, a variable named selection will be created in the workspace, containing the value of the selected item.
You can refer the following MathWorks documentation for more information on assignin function:
https://www.mathworks.com/help/releases/R2019a/matlab/ref/assignin.html
  댓글 수: 2
wenchao zhang
wenchao zhang 2024년 5월 25일
편집: wenchao zhang 2024년 5월 25일
hi, Animesh, your suggestion works well, thanks.
wenchao zhang
wenchao zhang 2024년 5월 25일
편집: wenchao zhang 2024년 5월 25일
if i just want creat a popup menu during the m script runing, it seems use listdlg will more convenient, and the script will stop to wait for the user to do the selection.
list = {'Red','Yellow','Blue',...
'Green','Orange','Purple'};
[indx,tf] = listdlg('ListString',list);

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

추가 답변 (0개)

카테고리

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

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by