I have a problem while i'm trying to plot some data // Error using matlab.gra​phics.axis​.Axes/set

115 views (last 30 days)
Error using matlab.graphics.axis.Axes/se
Value must be a 1x2 vector of numeric type in which the second element is larger than the first and may be Inf
This is the message that appears in the command window

Answers (2)

Walter Roberson
Walter Roberson on 5 May 2018
You would get that if you tried to set() the axes XLim or YLim for a regular numeric plot, but you had a problem with the values you passed.
When you set() XLim or YLim, you need to pass a vector of exactly two elements. Both elements must be numeric -- you cannot set the XLim for a numeric plot to be datetime() values for example. Neither element may be nan. The second element must be strictly greater than (not equal to) the first. It is acceptable for the first element to be -inf and it is acceptable for the second element to be +inf.
For example, using [9 3] or [9 9] would not be accepted because the second element is not strictly greater than the first.
  2 Comments
Bachtiar Muhammad Lubis
Bachtiar Muhammad Lubis on 6 Feb 2019
@walter roberson : i have passed handle.axes1 object. and then i got error same as him. what would i do to solve then sir ? while i passed handle.object from my another program ito xlim() t worked properly.
Walter Roberson
Walter Roberson on 6 Feb 2019
At the time you do the set(), what is the XLim or YLim that you are trying to set, and what is the datatypes of the xdata and ydata of what you graphed ?
You could get this problem with one axes but not another if the two axes were different kinds of axes. For example if one axes was a datetime axes then it would be fine to set datetime xlim for it, but it would not be acceptable to set datetime xlim for a numeric axes.

Sign in to comment.


Akash kumar
Akash kumar on 22 Mar 2021
Edited: Akash kumar on 22 Mar 2021
Dear Luis Salas,
These Problem occur:-- if you do not properly assgin the axis like :-- axis([50 8 50 85]);-- Gives the error:- because 1'st element value is less than the second element value (in x axis part), similarly for y axis.
Proper assginment of the aforementioned example is:-axis([50 80 50 85]);

Community Treasure Hunt

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

Start Hunting!