How to use set() to put multiple y-data points on plot
19 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Carmelo Gonzales
le 30 Juin 2016
Modifié(e) : Carmelo Gonzales
le 30 Juin 2016
Hello,
I am working on a project that displays live data from a load cell on a matlab plot, so the user can see whether or not the equipment is functioning properly. I need to show six sets of y-data across the same time span all on the same plot. I tried using the standard 'hold on' with plot(data(:,ii)) in a for loop, but this is just too slow. From what I've been reading, the set() command will work wonders (and already has), but I'm having trouble getting all of the data on the plot at once. What I have right now is something like this.
data=[force and time data in here] (500x7 matrix)
plotdata=plot(nan) used to create a plot with nothing in it so far
for ii=1:length(data)-1
set(plotdata,'XData',data(:,end),'YData',data(:,ii))
drawnow
end
As I loop through, the plot will update with the data in whichever column the loop is on, but on the next iteration it goes away and the new data shows. I tried using hold on but this was no help. Is there any way to keep all of the data on the plot using the set() command? I let the code run for almost 10 minutes and there wasn't even a hint of it slowing down, so I am confident this method will work, I just need to figure out how to get everything to stay on the plot. Thanks for your help.
Carmelo
0 commentaires
Réponse acceptée
Honglei Chen
le 30 Juin 2016
Do you know the size of data? If so, you can do something like
x = [rand(100,6) (1:100)']; % 100x7 matrix
plotdata = plot(x(:,end),nan(100,6));
for m = 1:6
set(plotdata(m),'YData',x(:,m));
drawnow;
end
HTH
2 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur National Instruments Frame Grabbers dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!