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.?

11 visualizzazioni (ultimi 30 giorni)
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 Commenti
Stephen23
Stephen23 il 27 Ago 2025
"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.
Steven Lord
Steven Lord il 27 Ago 2025
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.

Accedi per commentare.

Risposta accettata

Laudemir Carlos
Laudemir Carlos il 27 Ago 2025
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.

Più risposte (1)

Fangjun Jiang
Fangjun Jiang il 27 Ago 2025
@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 Commento
Stephen23
Stephen23 il 27 Ago 2025
"@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.

Accedi per commentare.

Community Treasure Hunt

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

Start Hunting!

Translated by