function [ratio_time,f,g]=twodsinnew(A,u0,v0,M,N)

tic     %Start timing
for r=1:M
  u0_x=u0*(r-1);
  for c=1:N
        v0_y=v0*(c-1);

        f(r,c)=A*sin(u0_x + v0_y);
    end;
end;

t1=toc;     %End Timing


tic
r=0:M-1;
c=0:N-1;
[C,R]=meshgrid(c,r);
g=A*sin(u0*R+v0*C);

t2=toc;    %End timing

ratio_time= t1/(t2+eps) % Eps in case of t2=0

% Running this function 
%[rt,f,g]=twodsinnew(1,1/(4*pi),1/(4*pi),512,512);
%g=mat2gray(g);
%imshow(g);

%[rt,f,g]=twodsinnew(1,1/(10*pi),1/(10*pi),512,512);
%[rt,f,g]=twodsinnew(1,1,1,512,512);
%[rt,f,g]=twodsinnew(1,1,1/(10*pi),512,512);