How do I add/create an interactive 3D plot on a MATLAB GUI?
41 次查看(过去 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 中查找有关 Surface and Mesh Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!