Borrar filtros
Borrar filtros

Creating a popup menu through a function.

2 visualizaciones (últimos 30 días)
stephen
stephen el 14 de Nov. de 2022
Comentada: Jan el 14 de Nov. de 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 comentario
Jan
Jan el 14 de Nov. de 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);

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Migrate GUIDE Apps en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by