Getting my listbox to connect with a graph

2 次查看(过去 30 天)
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