"If number belongs in the interval defined by a matrix" into code?
1 view (last 30 days)
Show older comments
Hello, I am trying to veto if two given numbers belong in two admissible ranges. Instead of writing line 11 that way, could I instead say something like if x_ini' does not belong to x_bound? Meaning that if the value of the first row of the transposed vector x_ini (i.e. x1_0) does not belong in the interval defined by the first row of matrix x_bound (i. e. x1_min x1_max) and/or, likewise, if the value of the second row of the transposed vector x_ini (i.e. x2_0) is not in the interval defined by the second row of matrix x_bound ((i. e. x2_min x2_max)), then that message is displayed?
Hopefully I have been clear? Thank you in advance for the help!
x1_min = 0.1;
x1_max = 2.0;
x2_min = 0.1;
x2_max = 2.5;
x_bound = [x1_min x1_max ; x2_min x2_max];
x1_0 = 1;
x2_0 = 1;
x_ini = [x1_0 x2_0];
if x1_0 < x1_min || x2_0 < x2_min || x1_0 > x1_max || x2_0 > x2_max
disp("Initial value of x does not belong in admissible interval.");
quit
end
2 Comments
Answers (0)
See Also
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!