I am having some trouble setting a figure returned by a .m file into matlab guide axis, I've tried different options but none of them work. I would like to get the figure when a pushbutton is pushed but the image is plotted in a separate figure. If somebody knows how to do this please let me know. Thanks!
Here is my code:
function varargout = MeshPlot(varargin)% MESHPLOT MATLAB code for MeshPlot.fig
% MESHPLOT, by itself, creates a new MESHPLOT or raises the existing
% singleton*.
%
% H = MESHPLOT returns the handle to a new MESHPLOT or the handle to
% the existing singleton*.
%% MESHPLOT('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in MESHPLOT.M with the given input arguments.
%% MESHPLOT('Property','Value',...) creates a new MESHPLOT or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before MeshPlot_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to MeshPlot_OpeningFcn via varargin.
%% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help MeshPlot
% Last Modified by GUIDE v2.5 20-Feb-2019 18:43:12
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @MeshPlot_OpeningFcn, ... 'gui_OutputFcn', @MeshPlot_OutputFcn, ... 'gui_LayoutFcn', [] , ... 'gui_Callback', []);if nargin && ischar(varargin{1}) gui_State.gui_Callback = str2func(varargin{1});endif nargout [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});else gui_mainfcn(gui_State, varargin{:});end% End initialization code - DO NOT EDIT
% --- Executes just before MeshPlot is made visible.
function MeshPlot_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 MeshPlot (see VARARGIN)
load('C:\Users\Elena\Desktop\TFG\Atlas Importantes\standard_vol.mat')load('C:\Users\Elena\Desktop\TFG\ScriptsTFG\surface_pial_both.mat')% cfg = [];
% cfg.dataset = [];
% handles.mesh1.pos = vol.bnd(1).pnt;
% handles.mesh1.tri = vol.bnd(1).tri;
% % mesh2.pos = vol.bnd(2).pnt;
% % mesh2.tri = vol.bnd(2).tri;
% % mesh3.pos = vol.bnd(3).pnt;
% % mesh3.tri = vol.bnd(3).tri;
% ft_plot_mesh(handles.mesh1, 'facecolor', 'cortex', 'edgecolor', 'none','unit', 'mm', 'facealpha', 0.1)
% % mesh2 = ft_plot_mesh(mesh3, 'facecolor', 'brain', 'edgecolor', 'none','unit', 'mm', 'facealpha', 0.2)
% % mesh3 = ft_plot_mesh(mesh2, 'facecolor', 'brain', 'edgecolor', 'none','unit', 'mm', 'facealpha', 0.2)
% hold on
% load('elec_realigned.mat')
% %mesh4 = ft_plot_sens(elec_realigned,'label','label','elecshape','sphere');
% handles.mesh = load('C:\Users\Elena\Desktop\TFG\ScriptsTFG\surface_pial_both.mat');
% ft_plot_mesh(handles.mesh, 'SpecularStrength', 0.3, 'facecolor', mesh.sulc, 'edgelighting', 'none','edgecolor', 'none','vertexcolor', mesh.sulc,'unit', 'mm', 'facealpha', 0.1, 'surfaceonly', 'false')
% % Choose default command line output for MeshPlot
handles.output = hObject;% Update handles structure
guidata(hObject, handles);% UIWAIT makes MeshPlot wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = MeshPlot_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;% --- Executes on button press in radiobutton1.
function radiobutton1_Callback(hObject, eventdata, handles)% hObject handle to radiobutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hint: get(hObject,'Value') returns toggle state of radiobutton1
% --- Executes on button press in radiobutton2.
function radiobutton2_Callback(hObject, eventdata, handles)% hObject handle to radiobutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hint: get(hObject,'Value') returns toggle state of radiobutton2
% --- Executes on slider movement.
function slider1_Callback(hObject, eventdata, handles)% hObject handle to slider1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hints: get(hObject,'Value') returns position of slider
% get(hObject,'Min') and get(hObject,'Max') to determine range of slider
% --- Executes during object creation, after setting all properties.
function slider1_CreateFcn(hObject, eventdata, handles)% hObject handle to slider1 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called
% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor',[.9 .9 .9]);endfunction editUmbral_Callback(hObject, eventdata, handles)% hObject handle to editUmbral (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hints: get(hObject,'String') returns contents of editUmbral as text
% str2double(get(hObject,'String')) returns contents of editUmbral as a double
% --- Executes during object creation, after setting all properties.function editUmbral_CreateFcn(hObject, eventdata, handles)% hObject handle to editUmbral (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white');end% --- Executes on selection change in popupmenu1.
function popupmenu1_Callback(hObject, eventdata, handles)% hObject handle to popupmenu1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hints: contents = cellstr(get(hObject,'String')) returns popupmenu1 contents as cell array
% contents{get(hObject,'Value')} returns selected item from popupmenu1
% --- Executes during object creation, after setting all properties.function popupmenu1_CreateFcn(hObject, eventdata, handles)% hObject handle to popupmenu1 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called% Hint: popupmenu controls usually have a white background on Windows.
% See ISPC and COMPUTER.if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white');end% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)c = cell(1,24);for i=1:24 c(1,i) = num2cell(1); endset(gca,'Tag','axes1')axes(findall(0,'Tag','axes1')) %set the axes as the current ones
%axes(handles.axes1);
Electrodes_Brain(c, 'cor')
Best Answer