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!!
답변 (1개)
Bhaskar R
2020년 2월 21일
req_data = rescale(data, 0, 5);
댓글 수: 3
A R
2020년 2월 21일
"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
A R
2020년 2월 25일
카테고리
도움말 센터 및 File Exchange에서 Enterprise Deployment with MATLAB Production Server에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!