[求助]初学MATLAB,求M脚本变M函数文件
<BR>请帮忙转为M函数文件:谢谢应该添加什么啊!!<BR><BR>% 读取图象数据到矩阵<BR> = imread('input.bmp');<BR>% 得到图象信息<BR>info = imfinfo('input.bmp');<BR>w = info.Width;<BR>h = info.Height;<BR>% 创建与图象大小相对应的网格<BR> = meshgrid(1:w,1:h);<BR>z = x - y + y - x;<BR>i = 1;<BR>j = 1;<BR>% 用图象灰度值填充高度值<BR>while (i - 1) * w + j <= w * h<BR>z(i,j) = A(i,j);<BR>j = j + 1;<BR>if j > w<BR>j = 1;<BR>i = i + 1;<BR>end <BR>end;<BR>% 绘制三维图象<BR>meshc(x,y,z);<BR>% 绘制表面<BR>surf(x,y,z,'FaceColor','interp','EdgeColor','none','FaceLighting','phong')<BR> function =plotbmp(fig)<BR>% 读取图象数据到矩阵<BR> = imread(fig);<BR>% 得到图象信息<BR>info = imfinfo(fig);<BR>w = info.Width;<BR>h = info.Height;<BR>% 创建与图象大小相对应的网格<BR> = meshgrid(1:w,1:h);<BR>z = x - y + y - x;<BR>i = 1;<BR>j = 1;<BR>% 用图象灰度值填充高度值<BR>while (i - 1) * w + j <= w * h<BR>z(i,j) = A(i,j);<BR>j = j + 1;<BR>if j > w<BR>j = 1;<BR>i = i + 1;<BR>end <BR>end;<BR>% 绘制三维图象<BR>meshc(x,y,z);<BR>% 绘制表面<BR>surf(x,y,z,'FaceColor','interp','EdgeColor','none','FaceLighting','phong')<BR><BR>
页:
[1]