Hi everyone, i need to do a dynamic plot.I have 2 vectors, x & y. So i have a coordinate (x,y). For example, i have (0,0) , (1,1), (3,3) , (4,4) and so on, and first i need a point or a dot at (0,0) and then (1,1). then (2,2) but (0,0) and (1,1) must still there in the plot. So the plot will be like a lot of points but ploted dynamically. This is my code:
clear all
clc
close all
table = readtable('laser_data.csv');array = table2array(table); for i = 1:length(array) %LEFT
hold on for k = 2:2:30 x = -0.018+array(i,k); y = 0.0899+array(i,k+1); xlabel('Distancia en el eje X') ylabel('Distancia en el eje Y') title('Obstáculos') h = scatter(x, y, 10, 'r'); drawnow limitrate %pause(0.00001)
end drawnow %FRONT
for k = 32:2:60 x = 0.05620-array(i,k+1); y = array(i,k); xlabel('Distancia en el eje X') ylabel('Distancia en el eje Y') title('Obstáculos') h = scatter(x, y, 10, 'r'); drawnow limitrate %pause(0.00001) end drawnow %RIGHT
for k = 62:2:90 x = 0.018-array(i,k); y = -0.0899-array(i,k+1); xlabel('Distancia en el eje X') ylabel('Distancia en el eje Y') title('Obstáculos') h = scatter(x, y, 10, 'r'); drawnow limitrate % pause(0.00001)
enddrawnowend
But it takes like 30 minutes to plot, and using this one: just takes 30 secs but i dont want lines, i want points.
table = readtable('laser_data.csv');array = table2array(table); h = animatedline('Marker','none');for i = 1:length(array) %LEFTfor k = 2:2:30 x = -0.018+array(i,k); y = 0.0899+array(i,k+1); xlabel('Distancia en el eje X') ylabel('Distancia en el eje Y') title('Obstáculos') addpoints(h,x,y) drawnow limitrate %pause(0.00001)end %FRONTfor k = 32:2:60 x = 0.05620-array(i,k+1); y = array(i,k); xlabel('Distancia en el eje X') ylabel('Distancia en el eje Y') title('Obstáculos') addpoints(h,x,y) drawnow limitrate %pause(0.00001)end %RIGHTfor k = 62:2:90 x = 0.018-array(i,k); y = -0.0899-array(i,k+1); xlabel('Distancia en el eje X') ylabel('Distancia en el eje Y') title('Obstáculos') addpoints(h,x,y) drawnow limitrate % pause(0.00001)endend
Best Answer