Getting my listbox to connect with a graph
1 次查看(过去 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 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Migrate GUIDE Apps 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!