How to create a look-up table and access different columns?

조회 수: 1 (최근 30일)
Himanshi Rani
Himanshi Rani 2018년 4월 6일
댓글: Himanshi Rani 2018년 4월 10일
I have two sets of precomputed data, namely Voltage,V and Resistance,R. For a value of Voltage, there is a Resistance value. I calculate new Voltage and need to know the (V,R) pair from the precomputed data sets which is closest to this new voltage value and also the corresponding resistance. How may I do that?

답변 (1개)

Gayatri Menon
Gayatri Menon 2018년 4월 10일
Hi,
Hope the below example helps you. I have created two sample matrices "V" and "R" and the new Voltage is named as "vin". "Vout" gives the voltage closest to "vin" from "V" matrix and "Rout" will be the corresponding Resistance value from "R" matrix.
vin=50;
V=[ 0 50 2 54 1 56 3];
R=[2 10 3 12 5 13 4];
[Vout index]= min(abs(vin-V));
Rout=R(index);
Thanks

카테고리

Help CenterFile Exchange에서 Data Type Conversion에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by