필터 지우기
필터 지우기

"If number belongs in the interval defined by a matrix" into code?

조회 수: 2 (최근 30일)
ABCDEFG HIJKLMN
ABCDEFG HIJKLMN 2021년 10월 27일
댓글: ABCDEFG HIJKLMN 2021년 10월 27일
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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by