Matlab Tutorials —— "figure & plot"

We always need figure to demonstrate the data we have.

Here gives an example of the basic way to use figure and plot:


% Start
x = -100:0.1:100;
y1 = x + 1;
y2 = x .* x;

figure(1); % create a new figure 1
plot(x, y1); % plot two curves in one figure
hold on; % To keep current curve appear
plot(x, y2);
% you can actually use the following one, it works the same
% plot(x,y1,  x,y2);
legend('y1', 'y2'); % add lengeds
title('Plot Demonstration'); % title of the plot
xlabel('x'); ylabel('y') % label of axis
axis([-5 5 -10 10]); % scale of axes [xmin xmax ymin ymax]
set(gca, 'XTick', (-5: 1: 5)); % set the step of axes [min: step: max]
set(gca, 'YTick', (-10: 2: 10)); 
grid on; % plot with grid on



% Other constructing method
x = 1:5:100;
Two = 3 * x - 2;

figure('Name', 'Two', 'NumberTitle', 'off'); % create 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值