How do I plot single points only when using apps?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
I am learning apps via online videos (which is quite informative by the way). The problem I am having is how to best plot single points when creating code as opposed to an entire line of data. For example:
% --- Executes on slider movement.
function slider1_Callback(hObject, eventdata, handles)
% hObject handle to slider1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'Value') returns position of slider
% get(hObject,'Min') and get(hObject,'Max') to determine range of slider
a = get(handles.slider1,'Value'); % Assigns instantanuous value of slider to a
x = 0:0.1:50; % Sets exact limits of x axis with step sizes of 0.1
y = sin(a*x); % Sets variable limits of y axis
plot(handles.axes1,x,y); % Plots values of x and y axis1 feature
This particular line of code adjusts data depending on a user's slider selection. I would like to know how to only show the instantaneous point of the slider within that axes1 display. What would I need to do? Additionally, if I were not to use a slider but an edit text box, how would that alter this line of code? If I can get some help with either in an example I believe I will be able to get back on track to creating my app. The end goal is to create a multi entry application that will show user entries (whether with a slider or edit text) in relation to one another in the same figure.
I appreciate all considerations ahead of time.
2 Kommentare
Antworten (1)
Cris LaPierre
am 6 Okt. 2021
I would set up the slider to go from 1 to the number of points in the waveform, and then use the slider to select the index to plot.
a = get(handles.slider1,'Value'); % Assigns instantanuous value of slider to a
x = 0:0.1:50; % Sets exact limits of x axis with step sizes of 0.1
y = sin(x); % Sets variable limits of y axis
plot(handles.axes1,x(a),y(a),'o'); % Plots values of x and y axis1 feature
I would likely make x and y app properties so that they do not need to be recalculated everytime the slider changes value.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Annotations finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!