I am using the serial port to read numbers from the arduino encoder. I did drawing a chart in app designer but in the X axis I only have the number of the next displayed number. I would like to see the time after which the number appeared in the X axis. The first number is e.g. 5 and in the x axis its time is 0, the next number 6 in the x axis appeared after 120ms and wants this time on the X axis.
delete(instrfind({'Port'},{app.PORT})) app.x=serial(app.PORT,'BAUD',9600); flushinput(app.x); fopen(app.x); % otwarcie portu szeregowego
for i=1:app.Zakres.Value drawnow if app.Z == 1 break end h = str2num(fscanf(app.x)); app.aPolozenie.Value = h; s = [s,h]; plot(app.UIAxes,s); app.UIAxes.YLim = [ app.Od.Value app.Do.Value]; app.UIAxes.XLim = [0 app.Zakres.Value]; pause(.0001); app.Zatrzymaj end end
I'm sorry for my English
my chart:
How to change X axis on time?
Best Answer