I have this code, which takes a meshgrid, and applies a transformation to every point:
function [newx, newy] = transform(x, y)
newx = 10 * x + y*y;
newy = 5 * y;
end
[x, y] = meshgrid(1:5, 1:5);
[u, v] = arrayfun(@transform, x, y);
I want to plot the new mesh in 2D. The closest I can get is to do so in 3D by adding a Z component of 0:
mesh(u, v, zeros(size(u)))
How can I get matlab/octave to just show this plot on a 2d set of axes?
meshgrid function returns two 2-Dimensional arrays representing the X and Y coordinates of all the points.
Description. [ X , Y ] = meshgrid( x , y ) returns 2-D grid coordinates based on the coordinates contained in vectors x and y . X is a matrix where each row is a copy of x , and Y is a matrix where each column is a copy of y . The grid represented by the coordinates X and Y has length(y) rows and length(x) columns.
Maybe I'm missing the point here, but what's wrong with a simple plot(u,v,'b-x',u',v','b-x')
?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With