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.

 채택된 답변

Matt J
Matt J 2023년 1월 17일
편집: Matt J 2023년 1월 18일

0 개 추천

s=([0 0 ; 0 1; 1 1; 1 0]-1/2)*20;
t=linspace(0,360,1000)';
c=[cosd(t), sind(t)];
patch('XData',s(:,1),'YData',s(:,2),'FaceColor','g','EdgeColor','b','LineWidth',3);
patch('XData',c(:,1),'YData',c(:,2),'FaceColor','r','LineStyle','none');
axis equal

댓글 수: 2

Hussein Haider
Hussein Haider 2023년 1월 18일
The edges are not blue
Matt J
Matt J 2023년 1월 18일
편집: Matt J 2023년 1월 18일
The edges are blue, but the thickness can be increased, which I have now done.

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

Matt J
Matt J 2023년 1월 17일
편집: Matt J 2023년 1월 17일

0 개 추천

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';

댓글 수: 2

Untitled
Undefined function 'nsidedpoly' for input arguments of type 'double'.
Error in Untitled (line 1)
c=nsidedpoly(1000);
Hussein Haider
Hussein Haider 2023년 1월 17일
i use MATLAB R2014a

댓글을 달려면 로그인하십시오.

Matt J
Matt J 2023년 1월 17일
편집: Matt J 2023년 1월 18일

0 개 추천

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

Hussein Haider
Hussein Haider 2023년 1월 18일
The edges are not blue
Matt J
Matt J 2023년 1월 18일
Now they are.
Hussein Haider
Hussein Haider 2023년 1월 18일
thank u

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Mathematics에 대해 자세히 알아보기

제품

릴리스

R2014a

태그

질문:

2023년 1월 17일

댓글:

2023년 1월 18일

Community Treasure Hunt

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

Start Hunting!

Translated by