How do I add/create an interactive 3D plot on a MATLAB GUI?
25 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponse acceptée
Luna
le 9 Jan 2019
Modifié(e) : Luna
le 9 Jan 2019
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 commentaires
Adam
le 9 Jan 2019
Why can you not just add it to your GUI in the first place instead of on a seperate figure?
Luna
le 9 Jan 2019
Modifié(e) : Luna
le 9 Jan 2019
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.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur 2-D and 3-D Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!