% --- Executes on button press in strline.
function strline_Callback(hObject, eventdata, handles)% hObject handle to strline (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
cla(handles.axes1,'reset');x=linspace(-10,10,500);axes(handles.axes1)hold onaxis([-10 10 -15 15])grid online(xlim,[0 0],'color','k','linewidth',3)line([0 0],ylim,'color','k','linewidth',3)y=x;plot(x,y)handles.Y=yhold offgatherandupdate(handles)% --- Executes on selection change in popupmenu2.
function popupmenu2_Callback(hObject, eventdata, handles)% hObject handle to popupmenu2 (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 popupmenu2 contents as cell array
% contents{get(hObject,'Value')} returns selected item from popupmenu2
% --- Executes during object creation, after setting all properties.
function popupmenu2_CreateFcn(hObject, eventdata, handles)% hObject handle to popupmenu2 (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 selection change in popupmenu3.
function popupmenu3_Callback(hObject, eventdata, handles)% hObject handle to popupmenu3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)gatherandupdate(handles,hObject)function gatherandupdate(handles)gathereddata=gatherdata(handles)updateaxes(handles.axes1,gathereddata)function gathereddata = gatherdata(handles)gathereddata.dong=get(handles.popupmenu3,'string') if strcmp(gathereddata.dong,'red') gathereddata.g=[1 0 0] elseif strcmp(gathereddata.dong,'green') gathereddata.g=[1 1 0] else strcmp(gathereddata.dong,'blue') gathereddata.g=[1 0 1] endfunction updateaxes(ax1,gathereddata)axes(ax1);axis([-10 10 -15 15])grid online(xlim,[0 0],'color','k','linewidth',3)line([0 0],ylim,'color','k','linewidth',3)x=linspace(-10,10,500);t=handles.Yplot(x,t,'color',gathereddata.g);hold off
I would like to store use the variable from str_linecallback() to the function updateaxes. I did refer the solutions of matlab users who had similar problems but I couldnt find a way to make mine work. Thanks.
Best Answer