Creating a popup menu through a function.

6 visualizzazioni (ultimi 30 giorni)
stephen
stephen il 14 Nov 2022
Commentato: Jan il 14 Nov 2022
I am creating a pop up menu in matlab to find different things related to probability the function needs compute the Sum of probabilities if selcted and return for the user to make another choice and end if the user selects quit. I am not sure if I am doing this correctly at all. just looking for some pointers to ensure I am on the correct path. I am also trying to avoid using GUI if possible
This is my code so far:
function y = p3(X,P)
countX = numel(X);
countP = numel(P);
if countX~=countP
error('Different number of outcomes and probabilities');
end
if countX == countP
h_fig = figure;
h_popup = uicontrol(...
'Style','popupmenu',...
'String',{'Sum of Probabilities','Expected Value','Variance','Standard Deviation', 'Quit'},...
'Callback',@mypopup_fcn,...
'Units','normalized',...
'Position',[0 0.5 1 0.5]);
h_textbox = uicontrol(...
'Style','edit',...
'Units','normalized',...
'Position',[0 0 1 0.5]);
function changetype(hObj,~)
case 1
s = sum(P);
h_textbox = ('The sum of the probabilities are ')
end
end
  1 Commento
Jan
Jan il 14 Nov 2022
"I am also trying to avoid using GUI if possible" - there are no popup menus without a GUI. So what does this mean?
The function changeType is not used, but mypopup_fcn is missing.
A case 1 requires a switch command before.
h_textbox = ('The sum of the probabilities are ')
I assume you mean:
h_textbox.String = sprintf('The sum of the probabilities are %g', s);

Accedi per commentare.

Risposte (0)

Categorie

Scopri di più su Migrate GUIDE Apps in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by