Plotting Multiple Data Streams with Timestamp

6 visualizzazioni (ultimi 30 giorni)
Hi everyone,
I am struggling to vertically concatenate data streams from 3 devices on to a singular timestamped plot. The data outputs do not have the same number of columns. (I have simulated this effect by populating with zeros.) Initially, my workaround was to copy and paste the data into a singular file to create a stackedplot from a time table with smaller datasets.
I have attached my code and some example data. See Data2 in comment below.
Is there a better way to plot multiple data streams with the same x-axis timestamp than manually concatenating the data using timetable and stackedplot?
Any advice would be much appreciated. Many thanks for considering my request!
  5 Commenti
dpb
dpb il 19 Nov 2020
Let's start with the basics -- how do you get the data from each device and what do you have that identifies what is in each?
Why can't you just read each file and plot what's in it and then go on to the next?
Is this in real time or post-processing data collected first?
CW
CW il 19 Nov 2020
Hi dpb,
Thank you so much for your continued feedback and assistance. The short version is that there is no practical way to synchronize the data streams from the device on the front end during data collection.
I have created stackedplots from timetables for the three .csv files output from the three devices, but generating a plot for all the data streams vs. the time stamp quickly during post-processing is invaluable for this application. Please see my response to Peter Perkins below for more details. I hope to post my solution within the next week.
Thanks again!

Accedi per commentare.

Risposta accettata

Peter Perkins
Peter Perkins il 19 Nov 2020
CW, if I am undersatand correctly, you are looking for the same kind of chart that stackedplot makes, for multi-rate data. The only way to get a stackedplot currently is to have one timetable. You'd want to horzcat your three different timetables, but you have multi-rate data, so the only way to "horzcat" them is to use synchronize to upsample or downsample to one common time vector.
It's hard to say from your figure if resampling would mess you up or not. It would be useful to hear if it would, and why. The obvious reason is that it would be either adding data that you don't really have, or removing data that you do have.
  2 Commenti
CW
CW il 19 Nov 2020
Thank you for your feedback, Peter! Your explanation confirms my understanding that only a single time table can be used for stackedplot. Thus, my current solution to force the three data streams into a single timetable via upsampling seems to be the best solution while still maintaining the original sampling rates. From what I can tell with the sample data, upsampling and plotting via "scatter" satisfies my needs. As much as I would love to downsample or solely have plots of each device's data streams, the "all data streams vs. timestamp" figure is a great tool to quickly relate positional data from an accelerometer to other data streams for post-processing. Once I get some decent data, I will be happy to share the resultant plot and code to this thread to assist others in the future. Thanks again!
Peter Perkins
Peter Perkins il 19 Nov 2020
Well hang on: I was perhaps responding to a question that you didn't actually ask, "how do I use stackedplot with timetables that have different sampling rates?"
If you want to make one scatter plot with the three sources overlayed, there's no reason why you can't use hold on to do that. And also, there's no reason why you can't make something like stackedplot by using subplots and setting the axis limits the same on each. Something like either one of these might fit your needs:
tt1 = timetable((1:100)'/100,'StartTime',seconds(0),'SampleRate',100);
tt2 = timetable((1001:2000)'/1000,'StartTime',seconds(0),'SampleRate',1000);
plot(tt1.Time,tt1.Var1);
hold on
plot(tt2.Time,tt2.Var1);
hold off
subplot(2,1,1);
plot(tt1.Time,tt1.Var1);
xlim(seconds([0 1]));
subplot(2,1,2);
plot(tt2.Time,tt2.Var1);
xlim(seconds([0 1]));

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su 2-D and 3-D Plots in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by