/* * rt_look1d.cpp * * Academic License - for use in teaching, academic research, and meeting * course requirements at degree granting institutions only. Not for * government, commercial, or other organizational use. * * Code generation for model "VFControl". * * Model version : 1.1 * Simulink Coder version : 24.1 (R2024a) 19-Nov-2023 * C++ source code generated on : Wed Oct 16 10:45:53 2024 */ #include "rt_look.h" #include "rtwtypes.h" #include "rt_look1d.h" #ifdef __cplusplus extern "C" { #endif /* 1D lookup routine for data type of real_T. */ real_T rt_Lookup(const real_T *x, int_T xlen, real_T u, const real_T *y) { int_T idx = rt_GetLookupIndex(x, xlen, u); real_T num = y[idx+1] - y[idx]; real_T den = x[idx+1] - x[idx]; /* Due to the way the binary search is implemented in rt_look.c (rt_GetLookupIndex), den cannot be 0. Equivalently, m cannot be inf or nan. */ real_T m = num/den; return (y[idx] + (m * (u - x[idx]))); } #ifdef __cplusplus } /* extern "C" */ #endif