1.1. 通过代码计算创建一幅512*512的图像需要多少时间;
由上图可知时间大概在0.0055秒。
2. 再用imshow与显示图像
3. 将其向量化
4. 最后用mashgrid重写这个函数并计算其时间
代码1
function f=twodsin1(A,u0,v0,M,N)
f=zeros(M,N);
for c =1:N
v0y =v0 (c-1);
for r=1:M
u0x = u0 (r-1);
f(r,c)=A*sin(u0x +v0y);
end
end
代码2
function f =twodsin2(A,u0,v0,M,N)
r =0:M-1;%Row coordinates.
c=0:N-1;%Column coordinates.
[C,R]=meshgrid(c,r);
f=Asin(u0R +v0*C);
在命令行输入要求的代码可得出图片所示