How to scale a value in matlab
11 views (last 30 days)
Show older comments
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!!
0 Comments
Answers (1)
Bhaskar R
on 21 Feb 2020
req_data = rescale(data, 0, 5);
3 Comments
Bhaskar R
on 21 Feb 2020
Edited: Bhaskar R
on 21 Feb 2020
"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
See Also
Categories
Find more on Digital Input and Output in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!