Draw circle in a rectangular
Show older comments
How to draw a Matlab code that draws a red circle with radius 1 at the center of a green square of sides 20. The square borders should be blue.
Accepted Answer
More Answers (2)
c=nsidedpoly(1000);
s=subtract(nsidedpoly(4,'Side',20),c);
h=plot([c,s]); axis equal
h(1).FaceColor='red';
h(1).FaceAlpha=1;
h(2).FaceColor='green';
h(2).EdgeColor='blue';
N=500;
[x,y]=ndgrid(linspace(-10,10,N));
cmsk=x.^2+y.^2>=1;
emsk=padarray(zeros(N-6),[3,3],1);
[R,G,B]=deal(~cmsk&~emsk,cmsk&~emsk,emsk);
I=cat(3,R,G,B);
imshow(I)
3 Comments
Hussein Haider
on 18 Jan 2023
Matt J
on 18 Jan 2023
Now they are.
Hussein Haider
on 18 Jan 2023
Categories
Find more on Mathematics in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

