3D plot surface

9 views (last 30 days)
GibonCZ
GibonCZ on 23 Mar 2022
Commented: GibonCZ on 1 Apr 2022
Hello ! I am working on a project that uses ultrasonic sensors to map objects in a room. The module is traveling in a straight line in the middle of a rooom at different altitudes and picking up objects closest to it . I am recording the date in vectors x(module movement) , y(sensor measurements) and z the module altitude. The picture shown illustrates a large object at 40cm floor level and another above it at 100cm between the module flight path and the wall.
I have used plot3 to create this 3d plot and its working fine although the quality will be improved . Is there any way to create a surface over all the points that would have been seen if loooking from the x axis ? I am trying to actually show the objects without the points. I have tried using mesh and other methods found on the matlab help pages but with no luck.
Any help would be much appriated :)

Answers (1)

Sam Chak
Sam Chak on 23 Mar 2022
The best is the provide a small sample of the spatial data for testing. Otherwise, the function surf can be used to create a surface plot. See the following example:
[x, y] = meshgrid(-pi:0.15:pi, -pi:0.15:pi);
z = (tanh(x - 1) + tanh(x + 1))/2 + ((tanh(x - 1) - tanh(x + 1))/2).*sign(y);
surf(x, y, z)
  1 Comment
GibonCZ
GibonCZ on 1 Apr 2022
Thank you Sam for getting back to me ! I am attaching the sample vectors that I am working with ( x,y,z) this is a small scan area of approximatly 1 m width and 40 cm height with two objects (boxes) in the view. All zero values were replaced with NaN with x(x==0) = NaN command.
Figure explanation - the scanning was performed at 3 differents heights with the first points at +- 120 being the wall , second at 60 being the first object and then 3rd object following at the right side of the plot.
I have tried surf function Z = meshgrid(z) , surf (x,y,Z) and this is what Im getting
Its getting closer but not quite there :) I would like for all the points to be joined together, creating a surface that can be seen from the x axis (0-100axis) so the objects can resemble the original ones. Also for some reason the points were duplicated and more were added to the graph , possibly because of the meshgrid. Any ideas for improvements ?

Sign in to comment.

Categories

Find more on Graphics Performance in Help Center and File Exchange

Tags

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!