How to make a callback from a pushbutton to a figure in MATLAB?

조회 수: 4 (최근 30일)
Demeter Andreea
Demeter Andreea 2019년 8월 14일
댓글: Geoff Hayes 2019년 8월 14일
Hei,
I wanted to ask you guys how I do the callback from this pushbutton from the main interface:
%PushButton Vc
uicontrol('Style','PushButton',...
'Units','normalized',...
'BackgroundColor',[0.0,0.0,0.0],...
'FontSize',8,...
'FontWeight','b',...
'ForegroundColor','W',...
'FontName','Consolas',...
'String','Matrice codare [Vc]',...
'Position',[0.08,0.15,0.12,0.08]);
To when I push the button to show me this new figure ( The code for figure is in another file saved):
%Figura Codare TORNADO
%--------------------------------------------------------------------------
figure()
set(gcf,'color','Black'); %setare background
%'Elementele matricii de codare liniara Tornado [Vc]'
uicontrol('Style','Text',...
'Units','Normalized',...
'Position',[0.1,0.6,0.5,0.4],...
'BackgroundColor',[0,0,0],...
'FontSize',12,...
'ForegroundColor','White',...
'FontWeight','b',...
'FontName','Consolas',...
'String','Elementele matricii de codare liniara Tornado [Vc]');
%Tabloul de valori
uicontrol('Style','Edit','Units','Normalize','position',[.1,.5,.6,.4],...
'Max',2,'String',num2str(Vc),'FontName', 'Consolas');
Thanks, please help
  댓글 수: 3
Demeter Andreea
Demeter Andreea 2019년 8월 14일
The problem is that it's that where I have that figure that I want to open pressing the pushbutton is just a file, not a function and if I try to make a function it gives me some errors, so I tried to open like this the file but still I have another erros now...
The code modified:
'Callback', run('FiguraVc.m'));
The errors:
Error using run
Too many output arguments.
Error in interf (line 217)
'Callback',run('FiguraVc.m'));
Error in mjfgkjsf (line 12) %the main program
interf(N,R,tip,s1,s2); % apel interfata
Geoff Hayes
Geoff Hayes 2019년 8월 14일
Demeter - is FiguraVc.m a script or a function? If a script, try converting it into a function that you can call from your callback function. So like Adam indicated,
'Callback', @myFunction
where
function myFunction(~,~)
FiguraVc;
end
where I'm assuming that FiguraVc is the name of the function defined in the FiguraVc.m file.

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Environment and Settings에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by