필터 지우기
필터 지우기

Copy a figure to UI

조회 수: 4 (최근 30일)
Shambhavi Adhikari
Shambhavi Adhikari 2020년 5월 18일
댓글: Tommy 2020년 5월 19일
I have a gcf generated in between the code and i want to project it to a UI. I am doing this so that a user with no MATLAB can still see my figure after i convert my code to standalone application (exe).
But, i am running into issues. Can you please help me here? This does nothing.
hf=gca;
uicontrols = findall(hf,'Type','uicontrol','Parent',hf);
% Specifying the parent will remove children of children of hf from the list
childObjects = get(hf,'Children');
types = get(childObjects,'Type');
uicontrolIndecies = strcmp(types,'uicontrol');
uicontrols = childObjects(uicontrolIndecies);
set(0,'units','pixels');
Pix_SS = get(0,'screensize');
% Generate a figure
width = 800;
height = 600;
height_offset = Pix_SS(4) - height - 100;
fig = uifigure('Name','Plot1','Position',[50 height_offset width-50 height]);
set(fig,'Resize','off');
p = uipanel(fig,'Position',[50 height_offset-100 width height]);
copyobj(uicontrols,p);
  댓글 수: 2
Christophe
Christophe 2020년 5월 19일
In the first line, gca is the current axes handle. In the second line, you are searching for uicontrols inside the axis object.I don't think you can find anything inside an axis. And the function copyobj may not work withthe "new" uifigure.
Tommy
Tommy 2020년 5월 19일
I don't believe you need to use a uifigure if you want users without MATLAB to be able to see your figure. Have you tried compiling and running your program while leaving the figure as a figure object?

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Develop uifigure-Based Apps에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by