Getting my listbox to connect with a graph

조회 수: 3 (최근 30일)
Caitlin Hoying
Caitlin Hoying 2017년 11월 22일
편집: Walter Roberson 2017년 11월 22일
Hello,
I am new to MATLAB but I am creating a GUI for a project.
What I am trying to do with the GUI is have a list box with three different functions to select. Once a function is clicked, it will be plotted in the graph.
below is the callback but I have the three functions set up to be plotted, I'm just struggling on the technical aspects.
% --- Executes on selection change in listbox1.
function listbox1_Callback(hObject, eventdata, handles)
% hObject handle to listbox1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% squared function
% squared function
X=0:0.1:3
Y=2.^X
plot(X,Y), grid on
%graph ln(x)
x= [0 1 2 3 4 5 6 7 8 9]
y=log(x)
plot(x,y), grid on
%cos
t = -pi:0.01:3*pi;
plot(t,cos(t)), grid on
% Hints: contents = cellstr(get(hObject,'String')) returns listbox1 contents as cell array
% contents{get(hObject,'Value')} returns selected item from listbox1

답변 (0개)

카테고리

Help CenterFile Exchange에서 Specifying Target for Graphics Output에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by