본문 바로가기

Enginius/Matlab

contourf : Matrix의 값을 그림으로 보고 싶을 때

 아래 그림의 오른쪽과 같이 plot을 하고자 할 때 유용한 함수가 바로 contourf 이다. 

 매우 편리하다고 할 수 있다. 



A = zeros(20, 20);


for i=1:20

for j=1:20

A(i,j) = 1/sqrt(2*pi)*exp(-1/20*sqrt((i-10)*(j-10)*(i-10)*(j-10)));

end

end

A = A / max(max(A));


figure(1)

subplot(1,2,1);

imshow(A, 'InitialMagnification','fit' )

title('imshow');


subplot(1,2,2);

contourf( A , 10);

colorbar('FontSize', 15);

%colormap hot;

colormap bone

title(' contourf ');