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

2 visualizzazioni (ultimi 30 giorni)
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)

Risposte (1)

KSSV
KSSV il 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

Categorie

Scopri di più su Spline Postprocessing in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by