How do I add/create an interactive 3D plot on a MATLAB GUI?
33 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Akzeptierte Antwort
Luna
am 9 Jan. 2019
Bearbeitet: Luna
am 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 Kommentare
Adam
am 9 Jan. 2019
Why can you not just add it to your GUI in the first place instead of on a seperate figure?
Luna
am 9 Jan. 2019
Bearbeitet: Luna
am 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.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Surface and Mesh Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!