How to change the color of a graph line when using comet function?

조회 수: 2 (최근 30일)
Kylie Ellis
Kylie Ellis 2020년 4월 15일
답변: KSSV 2020년 4월 15일
Hi everyone! I was wondering if there is any way to change the color of the line being generated in my code to a different color?
%% System Clearing
clc;
clear all;
close all;
%% Walking/step Conditions
stepsL=1; %stepping to the left
stepsR=1; %stepping to the right
%% Random Walking - 2500 steps
for n = 1: 2500
x = rand ;
if (x >= 0.5)
stepsL = stepsL + 1; % if moving left
else
stepsR = stepsR + 1; % if moving right
end
location(n) = stepsL - stepsR; % location tracker for direction
end
comet(location)

답변 (1개)

KSSV
KSSV 2020년 4월 15일
[m,n] = size(Location) ; % hoping Location to be m*2 array
for i = 1:m
plot(Location(1:i,1),Location(1:i,2),'color','r')
drawnow
end

카테고리

Help CenterFile Exchange에서 Spline Postprocessing에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by