怎么在matlab中画两个函数图象

来源:学生作业帮助网 编辑:作业帮 时间:2024/05/05 06:17:38
怎么在matlab中画两个函数图象

怎么在matlab中画两个函数图象
怎么在matlab中画两个函数图象

怎么在matlab中画两个函数图象
1.如果你要画2个子图,那就用subplot函数,例如:
income = [3.2 4.1 5.0 5.6];
outgo = [2.5 4.0 3.35 4.9];
subplot(2,1,1); plot(income)
title('Income')
subplot(2,1,2); plot(outgo)
title('Outgo')
2.如果你要画两个曲线在一个图里,可以这样:
index=[1 2 3 4 5];
income = [3.2 4.1 5.0 5.6];
outgo = [2.5 4.0 3.35 4.9];
plot(index,income,'-r.',index,outgo,'-b*');
legend('income','outgo',);