How do I define and use a standard range written by variable
1 view (last 30 days)
Hi every one!
I want to define the standard range "690N to 1200N" (N has to be a positive and integer number).
hen when i get a number I want to check if the number that I got is in my range (690-1200 or 1380-2400 or 2070-3600 or...).
Thank you very much!
Ruger28 on 4 Feb 2020
N = 1;
RangedValues = [690*N:1200*9]; % set your range, assuming your values are always 690 and 1200 * N
Num2Check = 1459; % number to see if it is within range
if Num2Check >= RangedValues(1) && Num2Check <= RangedValues(end) % check greater than first value and less than last
disp('Number is within range');
% rest of code below since nnumber is within range