r*******y 发帖数: 1081 | 1 Here is an example of surf:
[x,y] = meshgrid(-2:0.1:2,-2:0.1:2);
surf(x,y,)
But Now I want to apply surf to my defined function myFun(x,y)
But I can not say surf(x,y,myFun(x.,y.))
So any suggestion? Thanks. | k**x 发帖数: 2611 | 2 I think the output of your defined function should be in matrix form. | r*******y 发帖数: 1081 | 3 But it is not the way I want. I just define a scalar function of two
variables.
So no way to apply surf to this kind of defined funciton? Thanks.
【在 k**x 的大作中提到】 : I think the output of your defined function should be in matrix form.
| Q***5 发帖数: 994 | 4 koox is right, you have to prepare a matrix first.
If your `f' function can only take two variables, you can do the following
to come up with that matrix:
[x,y] = meshgrid(-2:0.1:2,-2:0.1:2);
x1 = x(:);
y1 = y(:);
for k = 1:length(x1)
z1(k,1) = f(x1(k), y1(k));
end
z = reshape(z1, size(x));
surf(x,y,z)
【在 r*******y 的大作中提到】 : But it is not the way I want. I just define a scalar function of two : variables. : So no way to apply surf to this kind of defined funciton? Thanks.
| r*******y 发帖数: 1081 | 5 thanks a lot. I learned something from your code.
【在 Q***5 的大作中提到】 : koox is right, you have to prepare a matrix first. : If your `f' function can only take two variables, you can do the following : to come up with that matrix: : [x,y] = meshgrid(-2:0.1:2,-2:0.1:2); : x1 = x(:); : y1 = y(:); : for k = 1:length(x1) : z1(k,1) = f(x1(k), y1(k)); : end : z = reshape(z1, size(x));
|
|