How can i fill a designed 3d circle in an axes matlab GUI object?

3 ビュー (過去 30 日間)
marco
marco 2014 年 8 月 25 日
回答済み: marco 2014 年 9 月 4 日
Hi everybody,
actually I've done a Matlab GUI with an object axes and a button. When i press the button, through a button callback, i draw a 3d circle through this function, passing the handles.axes:
function [crf] = EnvironmentSpace(origin_reference,index_col,figure_handles) %Draw the environment space with an enter circle shape acces point origin = origin_reference; radius = 0.10; %[m] angle = linspace(0,2*pi,150); crf(1,:) = origin(1)+radius*cos(angle); crf(2,:) = origin(2)+radius*sin(angle); crf(3,:) = origin(3);
col=hsv(128); index_trasp =0.5; h = figure_handles; plot3(h,crf(1,:),crf(2,:),crf(3,:),'-k','LineWidth',1); %fill3(crf(1,:),crf(2,:),crf(3,:),col(index_col,:), 'FaceAlpha',index_trasp); hold on;
I obatin the 3d circle in the axes object, but when i execute the fill3 instruction I obtain a filled circle in another figure and not in my axes object. I've already set the axes property 'NextPlot' with 'Add', but the problem still persists. I have the same problem with the command 'patch' for draw a 3d parallelepiped in the same axes object in which there is the 3d circle. Can anyone help me?
Morover, how can i set the X,Y,Z label, because in the axes object inspector i can't see the property XName or something like that, but only XLim,YLim,ZLim. Thanks in advance. Best regards.
Marco

採用された回答

Aykut Satici
Aykut Satici 2014 年 9 月 2 日
I have written a UI that implements what you want by slightly modifying your code. You can find it in the attachment. I could not really reproduce the issue you are experiencing. Could you be passing the figure handle in the function rather than the axes handle?
Also, note that, "plot3" and "fill3" are high-level graphics functions. If the figure on which you are trying to plot has 'HandleVisibility' property 'off' (or 'Callback' and you are not in calling "plot3" from a callback), then "plot3" may open another figure. You can use the low-level versions "line" and "patch" of these to get the same results, as implemented in the comment section in the sample code in the attachment.
You can set the x,y,z labels by using the functions "xlabel", "ylabel", and "zlabel", respectively. If you provide the axes handle to these functions as their first argument, you can be sure they are going to label the correct axes object. Again, see the provided sample code.

その他の回答 (1 件)

marco
marco 2014 年 9 月 4 日
Thanks Aykut,
yes the problem was that the handle visibility was switched off during the callback call. Thanks a lot !
Marco

カテゴリ

Help Center および File ExchangeGraphics Object Programming についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by