finding common rang between two different range?
7 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
shirin mhd
am 24 Mär. 2022
Kommentiert: shirin mhd
am 24 Mär. 2022
Hi everyone
I'm new to matlab and because of that my question may be so easy to others.I really appreciate your help.
I have x as my variable. and two range for it as below:
5<x<10
and
-6<x<6
and I want to find common range of them which should be 5<x<6. how can i do this in matlab?
im using version R2015b.
0 Kommentare
Akzeptierte Antwort
Image Analyst
am 24 Mär. 2022
Bearbeitet: Image Analyst
am 24 Mär. 2022
How about this:
range1 = [5, 10];
range2 = [-6, 6];
minValue = max([range1(1), range2(1)])
maxValue = min([range1(2), range2(2)])
if maxValue >= minValue
% The ranges overlap
commonRange = [minValue, maxValue]
else
% The ranges don't overlap
commonRange = []
end
It will work in your antique version.
Weitere Antworten (1)
Siehe auch
Kategorien
Mehr zu Introduction to Installation and Licensing finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!