Randomize a marker color for a graph

2 Ansichten (letzte 30 Tage)
Amanda
Amanda am 7 Nov. 2022
Beantwortet: David Hill am 7 Nov. 2022
im trying to randomize a color of a marker but it keeps giving me an error and even if i write out the full color it still doesnt work. i dont know how to fix this.
  1 Kommentar
Rik
Rik am 7 Nov. 2022
You don't actually index your array of letters. How do you expect Matlab to guess what you intended to do?

Melden Sie sich an, um zu kommentieren.

Antworten (1)

David Hill
David Hill am 7 Nov. 2022
m='o+*.x';
c='rgbcmyk';
x=randi(20,1,8);
y=randi(20,1,8);
figure;hold on;
for n=1:length(x)
scatter(x(n),y(n),'LineWidth',rand*8,'MarkerEdgeColor',c(randi(7)),'MarkerFaceColor',...
c(randi(7)),'Marker',m(randi(5)));
end

Kategorien

Mehr zu Creating and Concatenating Matrices 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