Getting my listbox to connect with a graph
1 view (last 30 days)
Show older comments
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 Comments
Answers (0)
See Also
Categories
Find more on Migrate GUIDE Apps in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!