Embed figure into Matlab GUI
조회 수: 10 (최근 30일)
이전 댓글 표시
Hi,
Can someone suggest how to call a figure that is automatically created by an embedded function in matlab and plot it within a GUI. The figure is generated by this embedded function as a pop-up. I tried using axes but am unable to get the actual handle for this figure. I have uploaded an image of the problem here
The code I have is this:
% --- Executes just before Unsupervisedfigureinsert is made visible.
function Unsupervisedfigureinsert_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to Unsupervisedfigureinsert (see VARARGIN)
% Choose default command line output for Unsupervisedfigureinsert
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes Unsupervisedfigureinsert wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = Unsupervisedfigureinsert_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
function pushbutton_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[Fi,Fo] = uigetfile('*.xlsx');
delete(strcat(Fo,'\','animals_withBMU.xlsx'));
A = xlsread(strcat(Fo,'\','animals_data.xlsx'));
sD = A;
msize = [3 3];
sMap=som_init(sD,msize,'random','hexa');
s = 'Training Commenced';
set (handles.outputstatement,'string',s);
sMap = som_train(sMap,sD, 2000); % som_train produces the pop-up figure
axes(handles.fig) % the Tag for the plot box is "fig"
set(gcf,handles.fig)
% --- Executes during object creation, after setting all properties.
function fig_CreateFcn(hObject, eventdata, handles)
% hObject handle to fig (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: place code in OpeningFcn to populate fig
댓글 수: 0
답변 (1개)
Image Analyst
2013년 6월 7일
I'm unable to bring up your web page, but you say " I tried using axes but am unable to get the actual handle for this figure." Well I assume you put an axes on your figure. Both your axes, and your figure have "tag" properties which is how you reference their handles, which are handles.figMainWindow and handles.axesImage, or whatever names you chose for them. I don't know why you say you are unable to get the handle for the figure - it's just handles.figMainWIndow or whatever name you chose. Anyway, you don't even need that at all to display an image into axesImage, just set that with the axes command or via the 'Parent' property in imshow:
axes(handles.axesImage); % or
imshow(yourImage, 'Parent', handles.axesImage);
Just make sure you don't issue a "figure" command beforehand otherwise it will create a new figure window and display the image in that instead of on your gui in the axesImage axes control.
댓글 수: 5
참고 항목
카테고리
Help Center 및 File Exchange에서 Dialog Boxes에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!