Borrar filtros
Borrar filtros

how to plot 3 different lines in single 3 d plot?

1 visualización (últimos 30 días)
Gowrishankar R
Gowrishankar R el 30 de En. de 2016
Comentada: Gowrishankar R el 1 de Feb. de 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?

Respuesta aceptada

Walter Roberson
Walter Roberson el 30 de En. de 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
  1 comentario
Gowrishankar R
Gowrishankar R el 1 de Feb. de 2016
can you suggest any tutorial/website where can i learn to draw real time 3D visualization of accelerometer using Matlab? what i am doing is i want to place accelerometer on the hand and i want to visualize the movement of the hand in real time?

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Language Fundamentals en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by