I am trying to implement a kind of lookup table in MATLAB.
I have data generated from a script with three variables swept, let's say var_a, var_b, var_c
. These are nested sweep, (var_a
-> var_b
-> var_c
)
And there are 10 outputs, out_01, out02, ..., out10
.
Now I have arranged the each output as out_01 = f(var_a,var_b,var_c)
, i.e., simply rearranging the data similar to nested loop.
My question is, how can I build a lookup table for such data?
I will give input like get out_01
@ certain var_a(X), var_b(Y), var_c(Z)
.
I have tried the following.
idx1_var_a = max(find(data.var_a <= options.var_a));
idx2_var_a = min(find(data.var_a >= options.var_a));
idx1_var_b = max(find(data.var_b <= options.var_b));
idx2_var_b = min(find(data.var_b >= options.var_b));
idx1_var_c = max(find(data.var_c <= options.var_c));
idx2_var_c = min(find(data.var_c >= options.var_c));
Y1 = interpn(data.var_c,data.var_b,data.var_a,data.out_01,data.var_c(idx1_var_c),data.var_b(idx1_var_b),data.var_a(idx1_var_a))
Y2 = interpn(data.var_c,data.var_b,data.var_a,data.out_01,data.var_c(idx2_var_c),data.var_b(idx2_var_b),data.var_a(idx2_var_a))
if Y1 == Y2
Y = Y1
else
Here I am unable to figure how to interpolate between these two output values,Y1, and Y2!!
end
Any help is welcome.