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 次查看(过去 30 天)
显示 更早的评论

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 个评论
Stephen23
2025-8-27
"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
2025-8-27
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.
- 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.
采纳的回答
更多回答(1 个)
Fangjun Jiang
2025-8-27
@Walter Roberson must be right. See below. Pause at line 531, check the value of minX and maxX.
plot(1:10)
xlim([5,5])
1 个评论
Stephen23
2025-8-27
"@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])
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 String Parsing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

