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

조회 수: 68 (최근 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 CenterFile Exchange에서 Interactive 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