I have the following function (z
) that should output a graphic which if sliced at f(x,y) = 0.001
the result image should be a message.
I wrote this code but I`m unable to slice it right
[x,y] = meshgrid(-1.5:0.3:1.5,-2.5:0.5:2.5) ;
z=exp(-4*x.^2-2*y.^2)*cos(8*x)+exp(-3*((2*x+1)/2).^2-6*y.^2);
% meshc (x,y,z, [0.001 0.001]);
meshc (x,y,z);
What did i miss?
You are likely looking for the countour
function instead of meshc
. meshc
plots a contour plot under a mesh plot, but you don't need a mesh plot to view the message. In fact, the countour
docs show an example of how to only plot a specific level:
contour(x, y, z, [0.001 0.001])
I also suspect that your function is not defined correctly. exp(...) * cos(...)
should probably read exp(...) .* cos(...)
:
The poor granularity leads me to believe that the sample spacing should be decreased (i.e., the grid should be made finer):
[x,y] = meshgrid(-1.5:0.003:1.5,-2.5:0.005:2.5);
Contouring the original function with the finer spacing also shows why I think *
should probably be .*
in the expression:
[x,y] = meshgrid(-1.5:0.003:1.5,-2.5:0.005:2.5);
z=exp(-4*x.^2-2*y.^2)*cos(8*x)+exp(-3*((2*x+1)/2).^2-6*y.^2);
contour(x, y, z, [0.001 0.001])
Unless the message is a count of sausage shapes, I think that the .*
version is more likely to contain useful information (looks like HI).