- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
matlab教程讲(暑期建模培训)
* Application of Matlab * 例3.15 条形图、填充图、阶梯图和杆图形式绘图 x = 0:0.35:7; y = 2*exp(-0.5*x); subplot(221);bar(x,y,g); title(bar(x,y,g));axis([0,7,0,2]); subplot(222);fill(x,y,r); title(fill(x,y,r));axis([0,7,0,2]); subplot(223);stairs(x,y,b); title(stairs(x,y,b));axis([0,7,0,2]); subplot(224);stem(x,y,k); title(stem(x,y,k));axis([0,7,0,2]); * Application of Matlab * 例3.16 极坐标图 polar函数用来绘制极坐标图,其调用格式为: polar(theta,rho,选项) 例:绘制ρ=sin(2θ)cos(2θ)的图形 theta = 0:0.01:2*pi; rho = sin(2*theta).*cos(2*theta); polar(theta,rho,k); * Application of Matlab * 3.3. 三维绘图的基本操作 三维线图指令plot3 三维绘图指令中,plot3最易于理解,它的使用格式与plot十分相似,只是对应第3 维空间的参量。 t=(0:0.02:2)*pi; x=sin(t); y=cos(t); z=cos(2*t); plot3(x,y,z,b-,x,y,z,bd); view([-82,58]); box on legend(链,宝石) * Application of Matlab * 三维线图绘制结果 * Application of Matlab * 三维网线图(mesh)和曲面图(surf) 画函数z=f(x,y)所代表的三维空间曲面,需要做以下的数据准备工作: 确定自变量的取值范围和取值间隔。 x=x1:dx:x2; y=y1:dy:y2; 构成x-y平面上的自变量采样“格点”矩阵。 利用MATLAB指令meshgrid产生“格点”矩阵 [xa, ya]=meshgrid(x,y)?; 计算函数在自变量采样“格点”上的函数值,即z=f(x,y)。 网线图、曲面图绘制。 * Application of Matlab * 举例 绘制函数z=x^2+y^2的曲面 x=-4:4;y=x; [x,y]=meshgrid(x,y); %生成 x-y 坐标“格点”矩阵 z=x.^2+y.^2; %计算格点上的函数值 subplot(1,2,1), mesh(x,y,z); %三维网格图 subplot(1,2,2), surf(x,y,z); %三维曲面图 colormap(hot); * Application of Matlab * 函数z=x^2+y^2的曲面的绘制结果 绘制结果 * Application of Matlab * 3.4. 图像文件的读写与图像显示 imread指令 读取图像文件( BMP, GIF , PNG, JPEG, and TIFF) imshow指令 显示图像 imwrite指令 保存图像 例:读取图像文件 img1=imread(‘mudan.jpg); % Load image data img2=imread(eight.tif); whos img1 img2 * Application of Matlab * Name Size Bytes Class img1 750x553x3 1244250 uint8 array img2 242x308 74536 uint8 array 显示图像: imshow(img1); % Display image * Application of Matlab * * Application of Matlab * lighter = 2 * img1; ? subplot(1,2,1); imshow(img1); title(Original); % Display image subplot(1,2,2); imshow(lighter); title(‘Lighter); % Display image 简单图像处理 * Application o
文档评论(0)