How to scale a value in matlab

11 ビュー (過去 30 日間)
A R
A R 2020 年 2 月 21 日
コメント済み: A R 2020 年 2 月 25 日
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
Bhaskar R 2020 年 2 月 21 日
req_data = rescale(data, 0, 5);
  3 件のコメント
Bhaskar R
Bhaskar R 2020 年 2 月 21 日
編集済み: Bhaskar 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
A R 2020 年 2 月 25 日
Thanks!! It really helped.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeDigital Input and Output についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by