필터 지우기
필터 지우기

Returning Plot handle From a function.

조회 수: 5 (최근 30일)
Tim Mottram
Tim Mottram 2012년 9월 25일
Hi Guys,
I have a function called myFill which uses the following commands to plot two filled areas:
f = fill(freqPoints,filledGood,goodColour,freqPoints,filledBad,badColour);
set(f(1),'EdgeColor',goodEdge,'FaceAlpha',0.5,'EdgeAlpha',1)
set(f(2),'EdgeColor',badEdge,'FaceAlpha',0.5,'EdgeAlpha',1)
I want to be able to add a line at a later point in my code so I know I need the handle to the plot. But when I try:
[ax,f] = fill(...)
I get the error "To many output arguments."
Can someone tell me how to return a handle to the plot, which can be used to up date it with a new line, please. Thanks in advance.
Kind regards,
Tim.

채택된 답변

Tim Mottram
Tim Mottram 2012년 9월 25일
편집: Tim Mottram 2012년 9월 25일
H = myFill
f = fill(freqPoints,filledGood,goodColour,freqPoints,filledBad,badColour);
set(f(1),'EdgeColor',goodEdge,'FaceAlpha',0.5,'EdgeAlpha',1)
set(f(2),'EdgeColor',badEdge,'FaceAlpha',0.5,'EdgeAlpha',1)
THEN
H = gca
end
Outside function:
hold on
H = plot(x,newLine)
hold off

추가 답변 (1개)

Wayne King
Wayne King 2012년 9월 25일
편집: Wayne King 2012년 9월 25일
you don't use two output arguments, just
h = fill()
If you want a handle to the current axes, you can just do
ax = gca;
with the plot active.

카테고리

Help CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by