How would you replace the following by meshgrid?
N=.33;
P=.45;
for i =1:10
for j=1:20
x0=i+N;
y0=j+P;
f(i,j)=exp(x0+y0);
end
end
How would you replace the following by meshgrid?
N=.33;
P=.45;
for i =1:10
for j=1:20
x0=i+N;
y0=j+P;
f(i,j)=exp(x0+y0);
end
end
I think something like
[X, Y] = meshgrid(1:10, 1:20);
Z = exp( (X+N) + (Y+P) );
% surf(X, Y, Z);
read here
edit
as user requested (if I've understood well):
[X, Y] = meshgrid(1:10, 1:20);
X1 = X + N; Y1 = Y + P;
Z = exp( X1 + Y1 );
% surf(X1, Y1, Z);
@Shin Takezou How would you do it without substituting the values in the function to modify it? That was what i meant.