Help needed in ploting graphs in GUI
- From: "Yousuf Siddiqui" <engr.yousuf.siddiqui@xxxxxxxxx>
- Date: Tue, 11 Sep 2007 14:13:14 +0000 (UTC)
I am trying to make a graph in the GUI which plots itself
when the user pushes a pushbutton. In this graph, I need to
plot the current data as well as the previous data.
That is suppose initially x=1 and y=7, and the plot shows
only the point (1,7) . The user pushes the push button, the
pushbutton callback locates the new value of y( let us
suppose that is 10) and then increments x by 1. Hence, the
new values are x=2 and y=10.
Now the plot must show a stright line between the previous
point (1,7) and the new point (2,10).
this processes, of pushing the pushbutton, can go an
arbitrary number of times and the graph must show all the
previous points as well as the new ones.
Here is the code I managed so far( this code uses
setappdata and getappdata in order to get the data from an
other GUI). Whenever I execute it, the graph shows only one
point. Any suggestions will be highly appreciated.
I will try to explain the code as best as possible
(statements with persentage before them are comments)
My program name is centralbasestationvalues.
% --- Executes just before centralbasestationvalues is made
visible.
function centralbasestationvalues_OpeningFcn(hObject,
eventdata, handles, varargin)
handles.output = hObject;
guidata(hObject, handles);
setappdata(0,'increment',1); %initially set increment to 1
% --- Executes on button press in updatecentral.
function updatecentral_Callback(hObject, eventdata, handles)
if get(hObject,'Value')==get(hObject,'Max')
%execute on button press
mssen=getappdata(0,'centralpower');
%centralpower is a variable calculated in another GUI
inc=getappdata(0,'increment');
%get value of increment, initially from the opening
function, later from the new value calculated below.
mssen_array(inc)=mssen;
%make a array with name mssen_array so as to record values
plot(inc,mssen_array);
axes(handles.msgraph);
%plot the graph on axes with handles msgraph between inc
and mssen_array.
inc=inc+1;
%increase inc by one
setappdata(0,'increment',inc);
%set the value of increment equal to the new value of inc
end
.
- Prev by Date: user-made dft error
- Next by Date: Getting rid of white frames for figures
- Previous by thread: user-made dft error
- Next by thread: dft error
- Index(es):