Hatch Pattern inside a circumference

조회 수: 4 (최근 30일)
AlphaReign
AlphaReign 2019년 9월 10일
댓글: Shubhobrata 2020년 9월 15일
Hi all:
I've been searching how to fill a circle created by the viscircles function with a hatched pattern like '\' but all the functions posted on mathworks have resulted unsuccessful or with errors that I can't (or don't know how) to fix. Is there any easy way? The code I used to create such circle:
viscircles([0 0],2,'color',[0 0 0]);
Thank you.

채택된 답변

darova
darova 2019년 9월 11일
Try this
clc,clear
% generate points on the circel with equal spaces
y = linspace(-1,1,20);
x = sqrt(1-y.^2);
a = 20; % angle of lines
% rotation matrix
R = [cosd(a) -sind(a); sind(a) cosd(a)];
X = [-x; x]; % add another side of X
Y = [ y; y];
V = R*[X(:) Y(:)]'; % rotate
X = reshape(V(1,:),2,[]);
Y = reshape(V(2,:),2,[]);
plot(X,Y,'k') % Hatch pattern
hold on
viscircles([0 0],1);
hold off
  댓글 수: 2
AlphaReign
AlphaReign 2019년 9월 11일
Worked out wonderfully, thanks!
Shubhobrata
Shubhobrata 2020년 9월 15일
good one. thanks

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

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by