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 Center および File Exchange2-D and 3-D Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by