View a 2-d projection of a 3D object
13 views (last 30 days)
Show older comments
I tried usind the matlab function "view" but it doesn't give a projected face
0 Comments
Answers (1)
Shaik
on 11 May 2023
Hi Lovett,
The view function in MATLAB sets the camera viewpoint for the current figure, but it does not render the 3D object in perspective. To render a 3D object in perspective so that it appears to have depth in a 2D image, you can use the camproj and camva functions to adjust the camera projection and field of view (FOV). Here's an example:
% Generate some random data
x = randn(100,1);
y = randn(100,1);
z = randn(100,1);
% Plot the data as a 3D scatter plot
figure;
scatter3(x,y,z);
% Adjust the view to a projected 2D view from above
camproj('perspective'); % set perspective projection
camup([0 1 0]); % set camera up direction
campos([0 0 max(z)]); % set camera position
camva(30); % set camera view angle
See Also
Categories
Find more on Lighting, Transparency, and Shading in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!