function [rt,f,g] = twodsin(A,u0,v0,M,N)ticfor r = 1:Mu0x = u0*(r-1);for c = 1:Nv0y=v0*(c-1);f(r,c) = A*sin(u0x + v0y);endend t1=toc;ticr = 0:M-1;c = 0:N-1;[C,R] = meshgrid(c,r);q = A*sin(u0*R + v0*C);t2= toc;rt = t1/(t2+ eps);在命令窗口出现
来源:学生作业帮助网 编辑:六六作业网 时间:2024/10/06 11:45:39
function [rt,f,g] = twodsin(A,u0,v0,M,N)ticfor r = 1:Mu0x = u0*(r-1);for c = 1:Nv0y=v0*(c-1);f(r,c) = A*sin(u0x + v0y);endend t1=toc;ticr = 0:M-1;c = 0:N-1;[C,R] = meshgrid(c,r);q = A*sin(u0*R + v0*C);t2= toc;rt = t1/(t2+ eps);在命令窗口出现
function [rt,f,g] = twodsin(A,u0,v0,M,N)
tic
for r = 1:M
u0x = u0*(r-1);
for c = 1:N
v0y=v0*(c-1);
f(r,c) = A*sin(u0x + v0y);
end
end
t1=toc;
tic
r = 0:M-1;
c = 0:N-1;
[C,R] = meshgrid(c,r);
q = A*sin(u0*R + v0*C);
t2= toc;
rt = t1/(t2+ eps);
在命令窗口出现错误:
>> [rt,f,g] = twodsin(1,1/(4*pi),1/(4*pi),512,512);
One or more output arguments not assigned during call to 'E:\matlab7\work\twodsin.m (twodsin)'.
function [rt,f,g] = twodsin(A,u0,v0,M,N)ticfor r = 1:Mu0x = u0*(r-1);for c = 1:Nv0y=v0*(c-1);f(r,c) = A*sin(u0x + v0y);endend t1=toc;ticr = 0:M-1;c = 0:N-1;[C,R] = meshgrid(c,r);q = A*sin(u0*R + v0*C);t2= toc;rt = t1/(t2+ eps);在命令窗口出现
% 输出参数 g 未赋值