Clear Filters
Clear Filters

I need the graph to be plotted inside the axes of GUI instead of popping out.

2 views (last 30 days)
% --- Executes on button press in correlation.
function correlation_Callback(hObject, eventdata, handles)
% hObject handle to correlation (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%eeg_data=str2double(get(handles.input,'String'
# * Item one
# * Item two));
if isfield(handles,'window_orig')
disp('Correlation is being calculated...')
[c d]=size(handles.eeg_data);
TH_corr=handles.TH_corr;
[correlation,y1]=correla(handles.window_orig,c,TH_corr);
handles.correlation=correlation;
handles.y1=y1;
handles.axes1=y1;
% [p q]=size(handles.correlation);
guidata(hObject,handles)
disp(handles)
else
disp('No Data Found!!!')
end
function [correlation,y1]=correla(window,c,TH_corr)
for h=1:c
for l=1:c
X=window(h,:);
Y=window(l,:);
ca=corr2(X,Y);
corr(h,l)=round(ca,2);
end
correlation=corr;
end
[p,q]=size(correlation);
for j=1:(p*q)
if(corr(j)< TH_corr && corr(j) > -TH_corr)
corr(j)=0;
end
end
disp('graph is being plotted....')
figure;
x3=graph(corr,'upper','OmitSelfLoops');
LWidths2= 5*x3.Edges.Weight/max(x3.Edges.Weight);
n1={'C3','C4','Cz','F3','F4','O1','O2','P3','P4','T3','T4'};
y1=plot(x3,'EdgeLabel',x3.Edges.Weight,'LineWidth',abs(LWidths2),'Layout','auto','NodeLabel',n1);
y1.Marker='s';
y1.NodeColor='r';
y1.MarkerSize=6;
y1.EdgeAlpha=0.3;
disp('Correlation is calculated')

Accepted Answer

Walter Roberson
Walter Roberson on 17 Jul 2018
Remove the
figure;
call.
  5 Comments
Walter Roberson
Walter Roberson on 17 Jul 2018
If you have a handle graphics object, then it would already be displayed unless the visibility of the object (or perhaps a container of the object) is set to Off. Unless, that is, what you stored in handles was data rather than the graphics object?
If you have an existing handle graphics object but you need to move it to a different container, then you can set its Parent property. If you have an existing handle graphics object but you need to copy it to a different container, then you can copyobj()

Sign in to comment.

More Answers (0)

Categories

Find more on Specifying Target for Graphics Output in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!