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

2 Ansichten (letzte 30 Tage)
Kylie Ellis
Kylie Ellis am 15 Apr. 2020
Beantwortet: KSSV am 15 Apr. 2020
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)

Antworten (1)

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

Kategorien

Mehr zu Spline Postprocessing finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by