MATLAB Answers

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

1 view (last 30 days)
Himanshi Rani
Himanshi Rani on 6 Apr 2018
Commented: Himanshi Rani on 10 Apr 2018
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?


Sign in to comment.

Answers (1)

Gayatri Menon
Gayatri Menon on 10 Apr 2018
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.
V=[ 0 50 2 54 1 56 3];
R=[2 10 3 12 5 13 4];
[Vout index]= min(abs(vin-V));

Sign in to answer this question.