Invalid axes handle error with gca?

I'm trying to write a function that places an inset axis on an axis given as an argument among other things, but I keep getting this invalid axes handle error when I try to run:
function aHanNew = magnifyingGlass(aHan, subdomain, insetPosition)
axes(aHan);
aHanNew = axes('position',insetPosition);
end
magnifyingGlass(gca,[0.001 0.1],[.6 .6 .25 .25]);
However when I alter the function to be
function aHanNew = magnifyingGlass(aHan, subdomain, insetPosition)
axes(gca);
aHanNew = axes('position',insetPosition);
end
It works just fine. When I call axes on gca directly it works, but when I call axes on a variable in which gca is stored it doesn't work. Why is this? and how can I get the first function to work correctly?

댓글 수: 3

Azzi Abdelmalek
Azzi Abdelmalek 2015년 7월 12일
What is the error message?
Mason Scott
Mason Scott 2015년 7월 12일
It will say "Error using axes, invalid axes handle"
Azzi Abdelmalek
Azzi Abdelmalek 2015년 7월 12일
I tested your code, there is no error message

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

답변 (1개)

Jan
Jan 2015년 7월 12일

0 개 추천

Perhaps you have shadowed the function gca by a variable with the same name? You can use the debugger to examine that. Simply set a breakpoinnt in teh offending line and check, what the name points to:
which gca

카테고리

도움말 센터File Exchange에서 Annotations에 대해 자세히 알아보기

태그

질문:

2015년 7월 12일

답변:

Jan
2015년 7월 12일

Community Treasure Hunt

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

Start Hunting!

Translated by