Embed figure into Matlab GUI
9 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (1)
Image Analyst
el 7 de Jun. de 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 comentarios
Ver también
Categorías
Más información sobre Dialog Boxes en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!