필터 지우기
필터 지우기

How to display two views of the same 3D plot in two different subplots

조회 수: 41 (최근 30일)
Matteo
Matteo 2024년 1월 31일
댓글: Matteo 2024년 1월 31일
Hi all!
I would like to display two views of the same 3d plot in two different subplots that I want to integrate in a GUI. Do I have to plot the same points in two different 3d plots or is possible to optimize the code and just display the same plot two times from different point of view. Also I want the two subplots to be interactive.
Thank you in advance for your help!
  댓글 수: 2
Dyuman Joshi
Dyuman Joshi 2024년 1월 31일
You will have to plot the data twice.
What does "interactive" mean in this context?
Matteo
Matteo 2024년 1월 31일
Thanks for the comment. By interactive I mean to be able to do thinks like zoom in or zoom out. Since I have to plot the thing twice there is no problem with this.

댓글을 달려면 로그인하십시오.

채택된 답변

Milan Bansal
Milan Bansal 2024년 1월 31일
Hi Matteo,
For plotting different views of the same 3d plot as different subplots, you need to plot the same curve in two subplots and set the viewing angle of each subplot using the "view" function.
Please refer to example shown in the code snippet below.
% For example, generate a 3d curve as shown below
[X, Y] = meshgrid(-5:0.5:5, -5:0.5:5);
Z = sin(sqrt(X.^2 + Y.^2));
figure()
% Create the first subplot with one view
subplot(1, 2, 1);
surf(X, Y, Z);
title('View 1');
view(30, 30); % Set the azimuth and elevation for the first view
% Create the second subplot with a different view
subplot(1, 2, 2); % 1 row, 2 columns, second subplot
surf(X, Y, Z);
title('View 2');
view(180, -30); % Set the azimuth and elevation for the second viewP
Please refer to the following documentation link to learn more about "view" function.
Hope this Helps!

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by