필터 지우기
필터 지우기

how do I create a handle to a plot without plotting?

조회 수: 38 (최근 30일)
Rick Giovanini
Rick Giovanini 2018년 1월 9일
답변: Pablo Saavedra G. 2019년 2월 18일
Hello, here is my code
function handle = DrawLink(z,w,h,handle)
pts = [z-w/2, z+w/2, z+w/2, z-w/2; 0, 0, h, h];
X = pts(1,:);
Y = pts(2,:);
if isempty(handle)
handle = fill(X,Y,'b');
end
end
I am trying to create a handle to the plot without plotting it while I make it. How do I do this? Thanks.

답변 (2개)

Star Strider
Star Strider 2018년 1월 9일
Try this:
fh = figure(1);
set(fh, 'Visible','off')
plot(rand(1,10), rand(1,10), 'p')
Then later, when you want to see it:
set(fh, 'Visible','on')
and it magickally appears!
  댓글 수: 4
Rick Giovanini
Rick Giovanini 2018년 1월 10일
So, I don't want to turn the whole plot off because I have other things that are plotted, and I have these things animated. I just want a handle to this, and then I need to do something to determine if I need to rotate it, and then to plot it, or just plot it first of all. In order to rotate without plotting, I need to have this handle.
Star Strider
Star Strider 2018년 1월 10일
I do not understand what you want to do, or what your requirements are.

댓글을 달려면 로그인하십시오.


Pablo Saavedra G.
Pablo Saavedra G. 2019년 2월 18일
You can always create an empty handle at the current axes and pass it to your function, for example:
handle = plot([],[],'-');
then in your function, the line with the if will get a TRUE
if isempty(handle)
handle = fill(X,Y,'b'); % note that previous handle (from plot) is repalced to fill
end

카테고리

Help CenterFile Exchange에서 Graphics Performance에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by