how to plot 3 different lines in single 3 d plot?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Gowrishankar R
le 30 Jan 2016
Commenté : Gowrishankar R
le 1 Fév 2016
i have accelerometer which gives 3 axis values.i read the data from accelerometer and plotting a graph. i succeeded in plotting only 1-axes value and the code is as shown below
[gx,gy,gz] = readAcc(accelerometer);
gxdata=[gxdata(2:end); gx];
plot(index,gxdata,'r');
axis([1 buf_len -3.5 3.5]);
i want to plot all gx,gy,gz values in a single 3D plot with different color lines.how to do that?
0 commentaires
Réponse acceptée
Walter Roberson
le 30 Jan 2016
If you have R2014b or later, I suggest you create some animatedLine with your desired maximum length, and addpoint() the data as it comes in.
If you are not trying to limit the length of the lines then I would suggest:
gdata = []; %initialize
for index = 1 : inf
[gx, gy, gz] = readAcc(accelerometer);
gdata = [gdata; gx, gy, gz];
plot(1:index, gdata);
drawnow();
end
Except that more efficient would be:
gdata = []; %initialize
hx = line(nan, nan, 'color', 'r'); %do not use [] to initialize them
hy = line(nan, nan, 'color', 'g');
hz = line(nan, nan, 'color', 'b');
for index = 1 : inf
[gx, gy, gz] = readAcc(accelerometer);
gdata = [gdata; index, gx, gy, gz];
set(hx, 'XData', gdata(:,1), 'YData', gdata(:,2));
set(hy, 'XData', gdata(:,1), 'YData', gdata(:,3));
set(hz, 'XData', gdata(:,1), 'YData', gdata(:,4));
drawnow();
end
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Resizing and Reshaping Matrices 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!