How to change the color of the most recent plot point?
조회 수: 3 (최근 30일)
이전 댓글 표시
I am trying to make something that will change the color of the most recent plot point.
This is my code so far:
%% Clear
clear;
close all;
clc;
%% matrix creation
b = [100,25,50,25; 50,50,50,50; 20,125,5,50; 5,10,15,170];
%% plot
times = length(b(:,1));
for k = 1 : times
R = b(k,1) + b(k,2);
L = b(k,3) + b(k,4);
T = b(k,1) + b(k,3);
B = b(k,2) + b(k,4);
sum = b(k,1) + b(k,2) + b(k,3) + b(k,4);
Rper = R/sum;
Lper = L/sum;
Tper = T/sum;
Bper = B/sum;
Hdist = 6.5;
Vdist = 4.25;
RHdist = Hdist * Rper;
LHdist = Hdist * Lper;
x = RHdist - LHdist;
TVdist = Vdist * Tper;
BVdist = Vdist * Bper;
y = TVdist - BVdist;
hold all
pause( 1 );
figure
plot(x,y,'o','MarkerFaceColor','k','MarkerEdgeColor','k')
xlim([-6.5 6.5])
ylim([-4.25 4.25])
ax = gca;
ax.XAxisLocation = 'origin';
ax.YAxisLocation = 'origin';
grid on
end
댓글 수: 0
답변 (2개)
KALYAN ACHARJYA
2019년 10월 22일
clear;
close all;
clc;
%% matrix creation
b = [100,25,50,25; 50,50,50,50; 20,125,5,50; 5,10,15,170];
%% plot
figure
times = length(b(:,1));
for k = 1 : times
R = b(k,1) + b(k,2);
L = b(k,3) + b(k,4);
T = b(k,1) + b(k,3);
B = b(k,2) + b(k,4);
sum = b(k,1) + b(k,2) + b(k,3) + b(k,4);
Rper = R/sum;
Lper = L/sum;
Tper = T/sum;
Bper = B/sum;
Hdist = 6.5;
Vdist = 4.25;
RHdist = Hdist * Rper;
LHdist = Hdist * Lper;
x(k)= RHdist - LHdist;
TVdist = Vdist * Tper;
BVdist = Vdist * Bper;
y(k)= TVdist - BVdist;
hold all
pause( 1 );
if k>=2
plot(x(k-1),y(k-1),'o','MarkerFaceColor','k','MarkerEdgeColor','k');
hold on;
end
plot(x(k),y(k),'o','MarkerFaceColor','r','MarkerEdgeColor','k')
xlim([-6.5 6.5])
ylim([-4.25 4.25])
ax = gca;
ax.XAxisLocation = 'origin';
ax.YAxisLocation = 'origin';
grid on
end
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Line Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!