Error using figure: First argument must be a figure object or a positive Integer

70 ビュー (過去 30 日間)
temp = uint32(1);
figure(temp);
Gives:
Error using figure
First argument must be a figure object or a positive Integer
If anything, 'temp' is definitly a positive integer. What is wrong? (Fix it Mathworks...)
  4 件のコメント
Jochem Bonarius
Jochem Bonarius 2018 年 8 月 7 日
@Stephen Cobeldick becasue the uint32 values come directly from a MySQL database (not mine to change). As a programmer it sounds insane that I have to recast these to double in order to get a 'mathematical integer' between 1 and 2^31-1. IMHO figure should just as well work with an int-type. I haven't encountered this using R, Python or Mathematica...
Stephen23
Stephen23 2018 年 8 月 7 日
編集済み: Stephen23 2018 年 8 月 7 日
"I haven't encountered this using R, Python or Mathematica..."
Sure, because other languages have their own "features", e.g. Python's default of integer division, which was a much more significant "feature" that caused far more people problems than this "feature" of MATLAB's. Both are documented too!
Comparing "features" like this is likely to be an endless game that no one wins.
"IMHO figure should just as well work with an int-type."
I totally agree. You should make a feature request: click "My Service Requests" at the bottom of this page:

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

採用された回答

Pawel Jastrzebski
Pawel Jastrzebski 2018 年 8 月 7 日
The doc says the input argument must be of double type:
  15 件のコメント
Jochem Bonarius
Jochem Bonarius 2019 年 7 月 26 日
編集済み: Jochem Bonarius 2019 年 7 月 26 日
One more thing
"% For plotting into a specific figure use:
FigH = figure;
plot(FigH, X, Y)"
Doesn't work. Just try it.
QED: so easy to get it wrong...It is just not user friendly.
Furthermore: if somebody closes the figure, it's handle disapears. If by accident, this could mean a script crashes. Could mean you lose a lot of simulation time. With the "figure(1);" method a new figure will just be opened... no crash...
Jan
Jan 2019 年 7 月 28 日
@Jochem: You are right, the figure handle is not correct to define the parent of a plot command. Of course an axes is needed. This was a too sloppy translation of my own handle graphic objects, in which this call is valid. See my edited code. Thanks for checking this detail.
figure(1) will work. The original question concerned figure(uint32(1)). Then the actual problem was the error message, which can be misunderstood by a person, who is not familiar with the Matlab language.
Did you write an enhancement request, such that Matlab fixes the error message?

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeInteractive Control and Callbacks についてさらに検索

タグ

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by