How to draw line with setting color for every point

조회 수: 2 (최근 30일)
john_arle
john_arle 2019년 11월 6일
댓글: Walter Roberson 2019년 11월 6일
hello there!
I am plotting a segment which moves in time. According to some conditions, I need the color of some point of the segment to change.
since I am redrawing the segment at every time step usign a line_handle, I need to set the color of every point of the segment at every time instant.
Then, I am shifting the vector.
To show you a simple example, I wrote a few lines (not working).
Thank you!!
In the code below, I get a warning:
'Warning: Error updating Scatter.
CData must be an RGB triplet, an M-by-1 vector of the same length as X, or an M-by-3 matrix.'
The thing is that when I run size(pe) I get 300 1,
size(color_pass) = 300 3.
So it should be correct!
for agent = 1:swarm.nb_agents
color_pass(1, :) = color(:, agent)';
for i = 2:self.wakes_length
color_pass(i, :) = color_pass(1, :);
end
pn = self.wakes(:, 3*(agent-1)+1);
pe = self.wakes(:, 3*(agent-1)+2);
pd = self.wakes(:, 3*(agent-1)+3);
hold on;
self.lines_handle(agent) = scatter3(...
pe, pn, -pd, 'SizeData', 4, 'CData', color_pass);
end
  댓글 수: 3
john_arle
john_arle 2019년 11월 6일
I have already tried! Sorry I had not edited the question in time!
Walter Roberson
Walter Roberson 2019년 11월 6일
Try dbstop if warning and examine the sizes of all of the parameters.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Discrete Data Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by