Trouble plotting a surface from N^2 3D vectors

1 view (last 30 days)
I am in need of a bit of assistance with surface plotting. N^2 3D vectors in an 3xNxN array, M.
where M( 1 , : , : ) are my X coordinates
M( 2 , : , : ) are my Y coordinates
and M( 3 , : , : ) are my Z coordinate.
I thought I could simply say
surf(X,Y,Z)
But that returns the error Z must be a matrix, not a vector or a scalar
I don't understand this as Z is a matrix, yes?

Answers (1)

Walter Roberson
Walter Roberson on 17 Nov 2015
X = squeeze(M(1,:,:));
Y = squeeze(M(2,:,:));
Z = squeeze(M(3,:,:));
surf(X,Y,Z)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!