how to map values of (3 to 4) to (1.4 to 4)?
thanks.

댓글 수: 2

KSSV
KSSV 2017년 12월 1일
An example will help..what do you mean by map?
Ramakrishna Bajaj
Ramakrishna Bajaj 2017년 12월 1일
I am reading values from the sensor and I am getting values from 3.3576 to 4.0811 not exactly approximately.
so I want to scale these values to 1.4 to 4. So that I can do comparison with my data.

댓글을 달려면 로그인하십시오.

 채택된 답변

M
M 2017년 12월 1일

0 개 추천

Suppose you have :
x=[3.35 3.4 3.8 3.9 4 4.08];
and you want to scale it to the interval [a b]
a=1.4;
b=4;
you can do it like this :
y = (x-min(x))*(b-a)/(max(x)-min(x)) + a;
y =
1.4000 1.5781 3.0027 3.3589 3.7151 4.0000

댓글 수: 1

Ramakrishna Bajaj
Ramakrishna Bajaj 2017년 12월 1일
what if I am not sure of min and max values? Then how should i deal with this and the values are changing real time.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Interpolation에 대해 자세히 알아보기

질문:

2017년 12월 1일

댓글:

2017년 12월 1일

Community Treasure Hunt

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

Start Hunting!

Translated by