How do I add/create an interactive 3D plot on a MATLAB GUI?
조회 수: 31 (최근 30일)
이전 댓글 표시
I try to embed an existing 3D plot on a separate GUI based on the example shown below:
I follow the procedure of manually implementing a GUI (aka not using MATLAB GUIDE) for which I want the 3D plot to be an (interactive) part of it (like a pushbutton). However, I have no clue how to add the pre-existing figure of the shown example to it, or how I would make use of the function copyobj correctly, assuming it's needed.
댓글 수: 0
채택된 답변
Luna
2019년 1월 9일
편집: Luna
2019년 1월 9일
Hi Joshua,
You can try below code:
You should create a panel, or an axes in some position and then add your plot to that container.
hFig = figure;
hAxes = axes('Parent',hFig);
x = 0:10;
y = 0:2:20;
z = rand(size(x,2),size(y,2));
hPlot = surf(hAxes,x,y,z);
hPlot.FaceAlpha = 0.7;
hPlot.EdgeAlpha = 0.3;
hPlot.FaceColor = 'interp';
hPlot.EdgeColor = [0 0 0];
hPlot.EdgeLighting = 'gouraud';
% you can change any other color or edge properties as you wish
rotate3d on;
댓글 수: 3
Adam
2019년 1월 9일
Why can you not just add it to your GUI in the first place instead of on a seperate figure?
Luna
2019년 1월 9일
편집: Luna
2019년 1월 9일
As I told above create your axis inside the figure using parent property:
You should define your strct under the handles so you can reach them from another function.
axis_handle = axes('Parent',strct.fighandle,'Position',[x,y,width,height],'XLim, YLim and ZLim properties');
sf_handle(sf_idx) = surface('coordinates & properties');
surf and surface functions both can have the axes handle in the first input and returns the surface object.
rotate3d on should work in both cases.
rotate3d on
Or share the entire code so that we can fix.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Graphics Object Programming에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!