Time vs Load plot

Hi, I have a load cell and would like to plot a time vs load graph. I can read the load however I am having trouble with x axis (Time).
The question is, how can I make an x axis that starts from 0 with the first measurement and has a sensivitiy at milisecond level. The duration of measurement could be a pre-set duration or limited with a number of iterations.

3 Comments

dpb
dpb on 8 Jun 2021
Is the sensor doing the sampling at a fixed rate and sending back those values? In that case, you can just create the time vector knowing the number of samples and sample rate.
If you're polling the sensor on a reading-by-reading basis, then you'll have to read a time signal from some place; the PC wall clock probably isn't high-enough resolution to avoid quite a bit of noise in the data.
Probably using tic and toc is the best can do...
may be of interest here.
Thank you for the answer!
I think it is the second case. I tried tic and toc and I placed the measurement command between them and here is what I see. So each measurement has a different duration.
Should I go on with tic - toc?
dpb
dpb on 8 Jun 2021
It would seem so, then, yes. You need to add in a return variable on LHS to save each duration, of course. The resulting time vector will be the cumsum() result of the individual observations.
And, of course, you'll want to preallocate the dt vector to the number of observations you're taking or a very large number so you aren't dynamically reallocating the vector each pass.

Sign in to comment.

Answers (0)

Categories

Find more on Graphics Performance in Help Center and File Exchange

Products

Release

R2021a

Asked:

on 8 Jun 2021

Commented:

dpb
on 8 Jun 2021

Community Treasure Hunt

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

Start Hunting!