How to use Cartesian coordinates to create Grid Surface?
Show older comments
Greetings,
I have been tasked with using Simscape Multibody to investigate contact forces between objects. One step in the Simscape process is to create a Grid Surface, as is described here: https://www.mathworks.com/help/sm/ref/gridsurface.html .
I am provided with CAD files (.stl) and have written a Matlab script that pulls in coordinate points from the STL that describe the shapes I'm interested in. It is simple enough to pull the X and Y values from the STL file and save them as vectors since Grid Surfaces require X and Y to be defined as "Coordinates in the x-direction or y-direction of the grid surface, specified as a real 1-by-m vector".
The Z values, however, are defined as "Elevations of the grid points in the grid surface, specified as a real m-by-n matrix. m and n are the lengths of the vectors for the X Grid Vector and Y Grid Vector parameters."
Does anybody have an idea of how to generate a Z-matrix given cartesian coordinates? I have manually done so with simple shapes, like a cube, but will need to eventually automate the process with a Matlab script.
Thanks
Answers (1)
If the CAD file describes the surface of the body in question, there should be a value for the elevation associated with each (x/y) pair. This is the z-matrix you are asking for.
x = 0:0.05:0.5;
y = 0:0.05:1;
z = x.^2+(y.').^2;
surf(x,y,z)
Categories
Find more on Bodies 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!