How can I draw a special circle separated by two colors?

Hi all.. I knew how to draw a complete circle separated by two color through asking question as following.
c=1+2j % circle centre
r=4 % radius
x=real(c)-r:0.01:real(c)+r
y1=sqrt(r^2-(x-real(c)).^2)+imag(c)
plot(x,y1,'r')
hold on
plot(x,-y1+2*imag(c),'b')
axis square
Ultimately, I am planning to draw two colored circles (including gray, white) of following picture.
Which code can I use to draw special circle?
I'd like to accept advice or idea from many people as far as possible.

Answers (1)

I'd do it in Photoshop and then just read it in as an image. Why do it the hard way like trying to recreate it via MATLAB? You haven't said if any of your parameters will change from run to run, so I'm assuming that they won't and they'll just use the constant values you gave, like radius = 4, etc. If any of them need to change on a run-by-run basis you should have / would have said so. So that's why I say to use Photoshop (or GIMP or Paint).

4 Comments

Haksun Lee comments:
"Thank you for your reply..
As you mentioned, I will change shape of special circle through communication. The end point of special circle will change according to current speed data. I assume that MATLAB receives speed data [150 100 50] through serial communication, and then the end point of special circle will change to location 150 -> 100 -> 50 like odometer. I'd like to draw special circle in MATLAB because the shape will change from run to run. I don't care about parameter if special circle can be drawn in MATAB Code.
I am waiting for your advice sincerely."
Can the rest of the image be assumed to be already constructed and read in as an image, so that only the gray and white arcs need to be added? Have you already attempted anything like the samples given in the FAQ?
Yes.. the rest of image was already constructed and read in as an image.
I have only to draw the gray and white arcs.
I can't draw arcs shape colored gray and white, but I tried seeing the samples given in the FAQ.
I have sample to draw special circle as following. At this code, I have serious problem because of 'for' sentence. Whenever data is changed, 'for' sentence is executed so program slows as updated data. How can I draw the special circle without 'for' sentence.
axes('units','pixels','pos',[56 165 280 300]);
x=[128 137 137 128 128];
y=[5 5 -5 -5 5];
for t=0:1:data_update
arm=fill(x,y,[0.5 0.5 0.5],'LineStyle','none');
angle=1.29*pi-0.00528*pi*t;
rot=[cos(angle) -sin(angle); sin(angle) cos(angle)];
updatecoordinate=rot*[x;y];
updateX=updatecoordinate(1,:);
updateY=updatecoordinate(2,:);
set(arm,'Xdata', updateX, 'Ydata', updateY);
end
try doing the inner and outer arcs then using poly2mask to get a binary image of the center of the arc filled in. Then apply the mask to the image
arcImage = poly2mask(coords, rows, columns);
grayImage(arcImage) = 200; % or whatever value the color gray is.
or something like that.

Sign in to comment.

Categories

Find more on MATLAB in Help Center and File Exchange

Tags

Asked:

on 25 Oct 2012

Community Treasure Hunt

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

Start Hunting!