Embed figure into Matlab GUI

23 vues (au cours des 30 derniers jours)
Vineet Guru
Vineet Guru le 7 Juin 2013
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

Réponses (1)

Image Analyst
Image Analyst le 7 Juin 2013
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 commentaires
Image Analyst
Image Analyst le 8 Juin 2013
Post a screenshot.
Vineet Guru
Vineet Guru le 9 Juin 2013

Connectez-vous pour commenter.

Catégories

En savoir plus sur Interactive Control and Callbacks dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by