Plotting Multiple Data Streams with Timestamp
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
CW
el 17 de Nov. de 2020
Comentada: Peter Perkins
el 19 de Nov. de 2020
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 comentarios
dpb
el 19 de Nov. de 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?
Respuesta aceptada
Peter Perkins
el 19 de Nov. de 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 comentarios
Peter Perkins
el 19 de Nov. de 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]));
Más respuestas (0)
Ver también
Categorías
Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!