Effacer les filtres
Effacer les filtres

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

41 vues (au cours des 30 derniers jours)
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 commentaires
Jochem Bonarius
Jochem Bonarius le 7 Août 2018
@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 le 7 Août 2018
Modifié(e) : Stephen23 le 7 Août 2018
"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:

Connectez-vous pour commenter.

Réponse acceptée

Pawel Jastrzebski
Pawel Jastrzebski le 7 Août 2018
The doc says the input argument must be of double type:
  15 commentaires
Jochem Bonarius
Jochem Bonarius le 26 Juil 2019
Modifié(e) : Jochem Bonarius le 26 Juil 2019
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 le 28 Juil 2019
@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?

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Interactive Control and Callbacks dans Help Center et File Exchange

Produits


Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by