A few days ago, I drew some curves on a same plot. And now I want to randomize the curve color.
Because the color syntax can be expressed as letters such as k, g, b etc. and also as a three element row, which indicate the RBG mode, such as [1, 0, 1], [0.1,0.7, 0.4] and so on.
So here I wrote a M-file to randomize the color and plot 10 curves in each subplot.
%this code produce a three element row
%which can be used to specify a random color
%created on 02/15/2010
function rndclr=f()
rndclr=[rand, rand, rand];
%this code draws some curves
%of random color
clf
t=0:0.01:100*pi;
for j=1:9
for i=1:10
hold all;
x=(i+2)*cos(t/i)+cos((i-1)*t);
y=i*sin(t/i)+sin((i-3)*t);
subplot (3,3,j);
plot(x,y,'color',rndclr)
axis('equal')
axis off
end
end
And here is the figure:
MATLAB applications, tutorials, examples, tricks, resources,...and a little bit of everything I learned ...
Subscribe to:
Post Comments (Atom)
my-alpine and docker-compose.yml
``` version: '1' services: man: build: . image: my-alpine:latest ``` Dockerfile: ``` FROM alpine:latest ENV PYTH...
-
It took me a while to figure out how to insert a space in Mathtype equations. This is especially useful when you write an equation with mult...
-
Recently I read post from Dr. Doug Hull's blog: http://blogs.mathworks.com/videos/2009/10/23/basics-volume-visualization-19-defining-s...
-
To get the slope of a pair of x and y, usually I first plot the curve and then add the trend line. Actually there are two functions i...
actually really helped me, just needed to use [rand,rand,rand] when trying to make a plot with n differently coloured graphs
ReplyDeleteI'm very glad to hear that!
ReplyDeleteThanks for commenting, Meredith.
Thanks! This is just what I needed, quick and helpful :)
ReplyDeleteI am glad to hear that, Dear Anonymous person :)
ReplyDeleteThanks.. it helped me too..
ReplyDeleteThe [rand rand rand] was helpful for me too, thanks for that.
ReplyDelete