How to scale a value in matlab

Hi, I have a 1x256 data (modulated data of an image) in the range -8.9 to 48.7 which i want to transmit to analog output pin 0 of MCC USB. (USB 205 has 2 analog output pins) The usb 205 only takes data within 0-5 V. So i converted my 1x256 data to 0-5 V using min and max function and pushed it to the DAQ and it works well.
z=1x256 data
b=min(z)
z1=z-b
c=max(z1)
Now i have to convert b and c values within 0-5V so that I can transmit these values to analog output pin 1 of daq. Please share your suggestions.
Thank you!!

Answers (1)

req_data = rescale(data, 0, 5);

3 Comments

Hello Bhaskar, the value i need to scale down is B= -6 and C=30.12
rescale(B, 0, 5); and rescale(C, 0, 5) both results in 0.
I want my B and C value between 0-5
"In statistics, the range of a set of data is the difference between the largest and smallest values - https://en.wikipedia.org/wiki/Range_(statistics). "
Here you are passing a single(for only 2 inputs aslo you get output as lower and upper limits as output) value to MATLAB function, that function is designed to set lower limit if you pass only single value as first input instead of set of data.
For the single/double input value you can apply thresholding condition but normalization can apply for set of the data(mupltiple values at a time)
>> x = 5:5:50
x =
5 10 15 20 25 30 35 40 45 50
>> rescale(x, 0, 5)
ans =
0 0.5556 1.1111 1.6667 2.2222 2.7778 3.3333 3.8889 4.4444 5.0000
You need to take at least 3 values of data so that to normalize
Thanks!! It really helped.

Sign in to comment.

Categories

Find more on Enterprise Deployment with MATLAB Production Server in Help Center and File Exchange

Tags

Asked:

A R
on 21 Feb 2020

Commented:

A R
on 25 Feb 2020

Community Treasure Hunt

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

Start Hunting!