Unexpected behaviour from ishandle()

Hi,
In a script, I was checking the existence of a plot handle to either make a new plot or to change the x/y data. Surprisingly this didn't work by initially setting the plot handle to []. Reason:
>> ishandle( [] )
ans =
[]
which sort of makes sense.
However, my next step was to initialise the plot handle to 0, which also didn't work, and this was the real surprise:
>> ishandle( 0 )
ans =
1
Even though
>> ishandle( 1 )
ans =
0
Does anybody why zero would be a valid graphics or Java object handle?
Thanks,
Temu

1 件のコメント

Temu Gautama
Temu Gautama 2019 年 11 月 22 日
I forgot to check the forum. Apparently, 0 is the root handle.
Temu

サインインしてコメントする。

 採用された回答

Stephen23
Stephen23 2019 年 11 月 22 日
編集済み: Stephen23 2019 年 11 月 22 日

0 投票

On MATLAB versions prior to R2016b zero is the handle to the graphics root (i.e. the parent of all graphics figures):
For compatilbility using zero is still permitted in later versions.

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeCreating, Deleting, and Querying Graphics Objects についてさらに検索

製品

リリース

R2015b

タグ

質問済み:

2019 年 11 月 22 日

編集済み:

2019 年 11 月 22 日

Community Treasure Hunt

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

Start Hunting!

Translated by