How I can solve this problem: Value must be a 1x2 vector of numeric type in which the second element is greater than the first element or is Inf.?

This is the part of txt file loaded:
1103.700 6281.0612
1103.750 6192.2908
1103.800 6195.5761
1103.850 6154.0272
1103.900 6207.6706
1103.950 6191.1954
1104.000 6219.1445
1104.050 6201.0625
1104.100 6140.0272
1104.150 6094.5643
1104.200 6125.0918
1104.250 6190.8243
1104.300 6145.3815
1104.350 6210.6124
1104.400 6226.1139
1104.450 6253.6217
1104.500 6229.4657
1104.550 6229.3967
1104.600 6265.9190
1104.650 6384.8658
1104.700 6300.0552
1104.750 6118.1145

6 commentaires

Can you set a breakpoint on line 531, perform the steps that lead to the error, then display the output of the following commands? This information will be helpful in determining the cause of the problem and the solution we can suggest.
This lets us determine if minX and maxX are scalars of a numeric type. If not, knowing something about app.BE likely will be useful in determining how to correct the problem.
whos minX maxX
class(app.BE)
size(app.BE)
This shows us the values of minX and maxX to let us know if maxX is greater than or equal to minX. It will also tell us if one of them is NaN.
minX
maxX
minX < maxX
minX == maxX

I predict that min x is the same as max x. Possibly BE is scalar or empty

dpb
dpb le 26 Août 2025
Modifié(e) : dpb le 26 Août 2025
I was going to predict that BE is an Nx2 array from the text file so both minX and maxX are each 2-vectors. :)
Thank you very much for the responses. Do you have any suggestions on how to modify the code to fix the problem? I already tried to add a line break on the line that is causing the issue, but it's simply not returning anything.
"Do you have any suggestions on how to modify the code to fix the problem?"
Show us the outputs of the commands that Steve Lord showed you here:
Adding random linebreaks is unlikely to fix anything. Please provide us with the information that Steven Lord requested.
Do you have any suggestions on how to modify the code to fix the problem?
Several, but they're not likely to do what you want.
  1. Replace line 531 with:
app.BGAxes.XLim = [0, 1];
This will avoid the error message, but depending on the values of minX and maxX this may not set the limits to the range you want.
2. You could eliminate line 531 and let MATLAB compute the axes limits automatically.
3. If app.BE is empty or not a vector, as Walter and dpb hypothesized, you could modify lines 528 and 529 to include the "all" dimension input argument in the min and max calls.
minX = min(app.BE, [], "all");
maxX = max(app.BE, [], "all");
You'd still have to detect the case where app.BE isempty and choose appropriate values for minX and maxX in that case.
4. If app.BE is not numeric, you could try to convert them to double before calling min and max.
Without the information about the sizes and classes of the variables involved in that code and the values of minX and maxX, we're just guessing as to the cause of the problem and how to resolve it. That's why I asked you to provide that information.

Connectez-vous pour commenter.

 Réponse acceptée

After carefully looking at the code, I noticed that a variable definition was a string and should have been a double. That's why I couldn't generate column X to read minX and maxX. I modified this and assigned the correct type and name to the variable. It ran!
Thank you so much.

Plus de réponses (1)

@Walter Roberson must be right. See below. Pause at line 531, check the value of minX and maxX.
plot(1:10)
xlim([5,5])
Error using xlim (line 37)
Limits must be a 2-element vector of increasing numeric values.

1 commentaire

"@Walter Roberson must be right."
No, there are other possibilities, for example dpb might be right:
app.BE = rand(7,2);
minX = min(app.BE);
maxX = max(app.BE);
plot(1:10)
xlim([minX,maxX])
Error using xlim (line 37)
Limits must be a 2-element vector of increasing numeric values.

Connectez-vous pour commenter.

Catégories

Community Treasure Hunt

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

Start Hunting!

Translated by