MatLab建模学习笔记1——二维绘图
来源:互联网 发布:c语言左移一位 编辑:程序博客网 时间:2024/05/21 10:04
MatLab的二维绘图功能
一、plot函数作图
x=0:pi/200:2*pi;
sin=sin(x);
cos=cos(x);
plot(x,sin,x,cos)
这样可以得到sin(x)和cos(x)在区间[ 0,2*pi ]的图像
区分不同图像的方法:
plot(x,sin,’r:’,x,cos,’b-.’)
图像的线性和颜色定义:
添加图像说明信息:
x=0:pi/100:2*pi;
sin=sin(x);
cos=cos(x);
plot(x,sin,’r:’,x,cos,’b-.’),xlabel(‘X’),ylabel(‘Y’),title(‘sin(x)和cos(x)图像’)
对图像曲线的说明:
text(2.8,0.5,’sin(x)’);
text(1.4,0.3,’cos(x)’)
axis设定坐标范围绘图:
x=linspace(0,2*pi,60);
y=sin(x);
plot(x,y);
axis([0,2*pi,-2,2]);
legend添加图例:
x=0:pi/100:2*pi;
sin=sin(x);
cos=cos(x);
plot(x,sin,’r:’,x,cos,’b-.’),xlabel(‘X’),ylabel(‘Y’),title(‘sin(x)和cos(x)图像’)
legend(‘sin(x)’,’cos(x)’)
二、Subplot函数拆分作图窗口
Subplot函数:对图像窗口拆分
Subplot(m,n,p),表示将当前图像窗口差分成m*n个,并且当前操作窗口为第p个。
x=linspace(0,2*pi,60);
y=sin(x);
z=cos(x);
t=sin(x)./(cos(x)+eps);
subplot(2,2,1);
plot(x,y);
title(‘sin(x)’);
subplot(2,2,3);
plot(x,t)
title(‘tangent(x)’)
Hold命令:在当前窗口中继续添加新的图像内容
x=linspace(0,2*pi,100);
sin=sin(x);
cos=cos(x);
plot(x,sin,’b’);
hold on;
plot(x,cos,’r’);
legend(‘sin(x)’,’cos(x)’);
hold off
三、函数作图
Fplot(f,range,err):其中f为函数名,range表示函数范围,err表示误差
fplot(‘[sin(x),cos(x)]’,[0 2*pi],1e-3,’r-‘)
四、特殊函数绘图
双对数函数:loglog
x=0:0.1:2*pi;
y=abs(1000*sin(4*x))+1;
loglog(x,y);
单对数函数:
x=0:0.1:2*pi;
y=abs(1000*sin(4*x))+1;
semilogx(x,y);
semilogy(x,y);
极坐标函数:polar
theta=0:0.01:2*pi;
y=sin(2*theta).*cos(2*theta);
polar(theta,y);
阶梯函数:stairs
x=-3:0.25:3;
y=exp(-x.*x);
stairs(x,y);
条形图形:bar
x=-3:0.25:3;
y=exp(-x.*x);
bar(x,y)
五、二维绘图函数
- MatLab建模学习笔记1——二维绘图
- MatLab建模学习笔记2——三维绘图
- matlab学习笔记(一)---二维绘图
- matlab学习笔记——绘图篇
- MatLab建模学习笔记3——MatLab工具箱
- [Matlab]基础教程学习笔记(四):二维高层绘图操作
- [Matlab]基础教程学习笔记(五):二维底层绘图修饰
- MatLab建模学习笔记6——数据拟合方法
- MatLab建模学习笔记7——线性规划问题求解
- MatLab建模学习笔记12——Logistic回归模型
- 《matlab从零到进阶》matlab练习1——二维绘图
- Matlab学习笔记——基本绘图功能
- matlab——二维绘图函数及部分参数
- Matlab学习笔记三:绘图
- MatLab建模学习笔记4——MatLab向Excel中读写数据
- MatLab建模学习笔记5——MatLab向TXT中读写数据
- 建筑建模学习笔记1——AutoCAD平面建模
- Matlab 二维绘图函数
- Groovy入门教程
- python的函数参数传递
- jQuery UI使用总结
- 计算几何 欧拉定理应用
- Myeclipse环境下 Springmvc注解式与hibernate框架整合具体步骤!
- MatLab建模学习笔记1——二维绘图
- bash: 09: value too great for base (error token is 09)
- JavaSE初步学习笔记(17天)
- 【Get深一度】谐振腔中的电场(E Field[V_per_m])与磁场(H field[A_per_m])分布
- java.lang.IllegalArgumentException: column '_id' does not exist 解决方法
- maven安装本地jar包
- android、ios与服务器端php使用rsa加密解密通讯
- freemarker常见语法大全
- 判断网络是否连接工具类