用MATLAB绘制函数图示
1 画图基础
(1)一元一次函数
x=0:0.1:1;
y=x;
plot(x,y); %图像见下图1
图1 图2
(2)一元多次函数
x=0:0.1:1;
y=x.^2;
plot(x,y); % 图像见图2
2 分段函数图像
x=0:0.1:2;
y=x.*(x>=0&x<=1)+(-(x-1).^2+1).*(x>1&x<=2);
plot(x,y); %图像见图3
%组合函数y=y1.*(x定义域)+y2.*(x定义域)
图3 图4
3 其他小技巧
(1)多条曲线画在同一个图像里
tip:使用 hold on 函数
t=[0:0.01:1];
q1=120-180*t.^2+120*t.^3;
q2=120-600*t.^3+900*t.^4-360*t.^5;
plot(t,q1);hold on;
plot(t,q2);
%图形见图4
(2)改变图像中线的颜色和线条形式(针对plot函数)
t=[0:0.01:1];
q1=120-180*t.^2+120*t.^3;
q2=120-600*t.^3+900*t.^4-360*t.^5;
plot(t,q1,'r');hold on;
plot(t,q2,'b');
%见图5
图5
通过在plot()函数括号里面增加特性来改变图线,常见的颜色和类型如图6
图6
(3)增加图例
tip:利用l egend 函数
t=[0:0.01:1];
q1=120-180*t.^2+120*t.^3;
q2=120-600*t.^3+900*t.^4-360*t.^5;
plot(t,q1,'r'); hold on;
plot(t,q2,'b');
legend('a)函数图像','b)函数图像') %要按函数的顺序来添加
%见图7
图7
上一篇: 用Java绘制简单数学函数图:例 - y = x²的图像画法
下一篇: Java画函数
推荐阅读
-
用C++实现Matlab中一维向量的fftshift函数
-
用Matlab解决多元方程,以三元方程为例,使用solve函数
-
绘制并理解Matlab中的cotx反余切函数图像
-
用MATLAB绘制图形:y等于7 times x除以(8减去7x)
-
简易指南:使用Matplotlib绘制数学函数图示
-
如何在MATLAB中绘制函数图:探索MATLAB常用的绘图功能
-
如何在Python中绘制函数图示
-
使用Matlab绘制函数图:一个强大的图形生成应用
-
如何在MATLAB中绘制双变量函数Z = 1 / (1 - x^2) + y^2,并用Python实现同样的二维二次曲面图展示
-
用Java绘制函数图形的方法教程