tags:

views:

29

answers:

2

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
+2  A: 

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);
ShinTakezou
A: 

@Shin Takezou How would you do it without substituting the values in the function to modify it? That was what i meant.

tevez
Huh? Also, this is not an answer. Please edit your question instead. I noticed you can't edit the question with your current login, since it appears you have more than one SO account. Sign into your original account to edit.
Doresoom

related questions