300x250
1. plot & figure
2. hold on;
3. grid on;
4. title
5. legend
6. xline / yline
- [축 or 상수 값 선] 생성
7. xlim / ylim
- 축을 기준으로 보이는 범위를 아래와 같이 지정
xlim([-40 40]);
ylim([x_1 x_2]);
8. annotation
dim = [.5 .3 .5 .6];
str = strcat('Max Val (SDev / DDev / DDelay) = ', num2str(Time(SAS_max_i)),'/',num2str(Time(Dyn_dev_i)),'/',num2str(SAS(Max_dyn_delay_SAS_i)));
annotation('textbox',dim,'String',str,'FontSize',8, 'FitBoxToText','on');
9. cla / clf
cla() # Clear axis
clf() # Clear figure
close() # Close a figure window
- 설명 자체는 위와 같이 간단하지만, cla를 사용하는 것을 추천.
- cla;를 지나게 되면 그 전까지 있던 모든 부분들 삭제
x_1 = -3;
x_2 = 20;
x_target = 0.5;
x = linspace(x_1, x_2, 100);
start_t = 9000;
end_t = 9900;
for i = start_t:end_t
y = A(i)*x.^3 - B(i)*x.^2 + C(i)*x - D(i);
y_val = A(i)*x_target^3 - B(i)*x_target^2 + C(i)*x_target - D(i);
cla;
plot(0,0, 'gs');
plot(-y_val, 0.5, 'bo');
hold on;
plot(-y,x);
grid on;
pause(0.01);
title(i);
xlim([-40 40]);
ylim([x_1 x_2]);
end
※ 순서 주의
figure - plot - hold - grid - title
figure;
x1 = linspace(0,5);
y1 = sin(x1/2);
plot(x1,y1)
hold on
x2 = [0 1 2 3 4 5];
y2 = [0.2 0.3 0.6 1 0.7 0.6];
scatter(x2,y2,'filled');
hold off;
legend('sin(x/2)','2016');
300x250