How to change the color of a graph line when using comet function?
2 views (last 30 days)
Show older comments
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)
0 Comments
Answers (1)
KSSV
on 15 Apr 2020
[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
0 Comments
See Also
Categories
Find more on Spline Postprocessing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!