Clueless: GUI graph datastream in realtime

1 view (last 30 days)
Pavel
Pavel on 20 Aug 2011
Hi!
I am pretty new to programming with Matlab so please dont yell at me too loud for asking stupid questions;
I am writing on a programm that displays and, upon a pushbutton callback, logs some pressure sensor data in real time.
The sensor data are retrieved by sending the sensor a query and listening to the answer. I put this in a loop to continuously receive Data. I already managed to display the Data by simply updating a static Text of the GUI while in the loop. Now I want to make it sexy by displaying the Data in relation to time by a graph but after 3 days of trying i give up.
What i want is a 2d yx-Graph with x representing time and y representing the pressure value. Since i receive data continuously It would be nice to have sort of an animatet graph that displays the last t minutes. For this I thougt about showing "now" on the far right of the X-Axis and the according y-value, then with the next looprun, have both move one timestep to the left and display the new value and the new "now" -point where the old ones have been before.
Does anybody have a clue for me how to start or for what kind of plots to look?
How can I turn my datestr(now,....) into somethiong matlab accepts as a value for the x axis?
Does anyone know any similar projetcs?
I would be very happy if someone had an idea.
thanks anyway for reading,
Cyber
P.S. This is the loop:
% --- Outputs from this function are returned to the command line.
function varargout = Controler_GUI_OutputFcn(hObject, eventdata, handles)
global Exitflag; % To exit the loop - flag is set by a push button of the GUI
global Writeflag; % To start/stop logging - flag is set by a toggle button
% Variables for the Logfile
global Filename;
global Filenamepath;
startline=2;
column='A';
while Exitflag==1;
axes(handles.axes1); % set axix1 as current active axes.
Depth=get(sensor, 'getdata'); % Just pseudocode here; receive newest pressure value
set(handles.text2,'String',Depth); % DISPLAY OF DATA IN DISPLAY
% DISPLAY DATA IN GRAPH
plot(handles.axes1,now,Depth); %complete mess- doesnt work
refresh;
if Writeflag==1; % record data ?
xlswrite(Filenamepath,Depth,Filename,strcat(num2str(startline),column));
startline=startline+1;
end
guidata(hObject, handles);
pause(0.2);
end
varargout{1} = handles.output;

Answers (0)

Categories

Find more on Specifying Target for Graphics Output 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!