How to compare a number with values of a vector?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Ahmad Hasnain
am 21 Sep. 2018
Beantwortet: Fangjun Jiang
am 21 Sep. 2018
I have a vector. For example
A = [20 40 60 80 100 120]
I have a number as an input in a function
function imp(omega)
I need to compare the number omega with all the numbers of the vector. For example, the number is 30. I know 30 is in between 20 and 40. How do I find that by code?
0 Kommentare
Akzeptierte Antwort
Fangjun Jiang
am 21 Sep. 2018
A = [20 40 60 80 100 120];
x=30;
lowB=interp1(A,A,x,'previous')
HighB=interp1(A,A,x,'next')
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Matrices and Arrays 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!