Study

matlab plot

greenpresent 2014. 10. 31. 10:21

matlab plot

matlab의 plot의 설명은 다음과 같다.

plot(Y) plots the columns of Y versus the index of each value when Y is a real number. For complex Y, plot(Y) is equivalent to plot(real(Y),imag(Y)).

 

그냥 간단히 그래프를 그려주는 함수라고 생각하면 된다.

기본적인 형식은 plot(t,a)    이다.

 

plot을 하기전에 figure를 쓰리도 하는데 이는 그래픽의 객체를 생성해주는것이라고 생각하면된다.

 

example

 

----------------------------------------------------------------------

>> db = [0:10:100]

db =

     0    10    20    30    40    50    60    70    80    90   100

>> MT1 = [7.7, 7.4, 7.8, 7.4, 6.8, 3.5, 3.3, 3.3, 3.1, 3.1, 3]

MT1 =

    7.7000    7.4000    7.8000    7.4000    6.8000    3.5000    3.3000    3.3000    3.1000    3.1000    3.000

>> MT2 = [7.5, 7.9, 7.6, 7.6, 7.3, 6.7, 6.1, 6.1, 6.1, 6.1, 6.1]

MT2 =

    7.5000    7.9000    7.6000    7.6000    7.3000    6.7000    6.1000    6.1000    6.1000    6.1000    6.100

>> figure
>> hold on          % plot할때마다 새로운창이 아니라 해당 그래픽에 같이 출력
>> grid on           % 눈금을 그려준다
>> plot(db, MT1, '-mo','LineWidth',2,'MarkerEdgeColor','k')
>> plot(db, MT2, '-b*','LineWidth',2,'MarkerEdgeColor','k')
>> legend('(1) 8:8:8','(2)14:8:8');     %그래프에 관한 설명
>> ylim([0 10]);                             % y축의 axis 설정
>> ylabel('Data Rate [Mbps]');       % y축 라벨표시
>> xlabel('attenuation [dB]');          % x축 라벨표시

----------------------------------------------------------------------

추가로 다음과 같이 타이틀을 설정해줄 수 있다.

>> title('title');  

 

========= color =========

k  : black

w : white

r  : red

b  : blue

g  : green

c  : cyan 

y  : yellow

m : magenta

 

========= line shape =========

--

-.

:

-

========= shape=========

*

.

o

x

+

s

d

 

v

>

<

p

h