본문 바로가기
삽질기초

MATLAB 원 그리기.

by @가을바람 2009. 11. 6.

center=[0 0];                     %중심점
r=200;                             %반지름
N=1000;                           %개수
theta=linspace(0,2*pi,N);       %원(라디안)
x=r*cos(theta)+center(1);      
y=r*sin(theta)+center(2);      
 plot(x,y);                      
 axis equal;                         %좌표축.



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
운동장 모양

설마 이건 헛진거리 한건 아니겠지 ㅠㅠ


clear all
clc

center=[0 0];                   %중심점
r=70;                          %반지름
N=1000;                         %원의 점 개수
NL = 600;                       %선의 점 개수*2



theta=linspace(0,2*pi,N);       %원(라디안)
x=r*cos(theta)+center(1);      
y=r*sin(theta)+center(2);      

plot(x,y);                      
hold on
%  axis equal;                     %좌표축.

%세로축으로 변경.
x = round(x');
y = round(y');
A  = [x,y];


%좌우 반원으로 나누기.
Lx = x((N/4)+1:3*(N/4));
Ly = y((N/4)+1:3*(N/4));

Rx = x(1:(N/4));            
Ry = y(1:(N/4));            
Rx = [x(3*(N/4)+1:N); Rx];
Ry = [y(3*(N/4)+1:N); Ry];

Rx = Rx+NL;
Lx = Lx-NL;

%중앙에 선그리기.
temp1 = [NL-1:-1:-NL]';
temp2 = [-NL+1:1:NL]';
Upx = temp1;
Lowx = temp2;


Upy = (ones(2*NL,1))*r;
Lowy = ones(2*NL,1)*-r;


x=[Lowx;Rx;Upx;Lx];
y=[Lowy;Ry;Upy;Ly];
plot(x,y)
axis equal;                     %좌표축.

grid on







'삽질기초' 카테고리의 다른 글

MATLAB & Simulink Based Books  (0) 2009.11.19
Power Systems book  (0) 2009.11.13
Model-Based Design 을 이용한 임베디드 시스템의 개발  (0) 2009.11.03
matlab shortcuts. 단축키.  (0) 2009.11.03
http://freebookspot.in/  (0) 2009.07.10