How to convert X, Y, Z cartesian coordinates into a surface.
Show older comments
Hello,
I have three vectors representing x, y, and z cartesian coordinates of half of a nosecone shape. I need to convert the z data into a "matrix of z heights", as as described in the documentation for Grid Surfaces used in Simscape Multibody (https://www.mathworks.com/help/sm/ref/gridsurface.html#mw_e7b9ffe5-592d-4971-9715-092dba7fd93a).
I tried to use the diag() command and surf() to check things, but it isn't quite right; there are valleys between rows of points and some of the negative space outside the nosecone is also included. Additionally, Simscape grid surfaces need x and y vectors that are monotonic and increasing. I can sort these vectors in Matlab easily enough, I can't seem to get my z matrix quite right when I sort x and y.
Sample code below. The x_coords, y_coords, and z_coords are pulled in from a .mat file.
Thank you!
load('cone_data - Copy.mat');
x = x_coords(:);
y = y_coords(:);
z = z_coords(:);
z = diag(z);
fullset = [x y z];
surf(x, y, z);
Accepted Answer
More Answers (0)
Categories
Find more on Applications in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

