Download MATLAB SIMULINK 7 - DEVELOPING S-FUNCTIONS User`s guide
Transcript
Fully Inlined S-Function with the mdlRTW Routine • How to use the mdlRTW routine to customize the Real-Time Workshop generated code to produce the optimal code for a given set of block parameters • How to generate an inlined TLC file for an S-function in a combination of the fully-inlined form and/or the wrapper form The Direct-Index Lookup Table Algorithm The 1-D lookup table block provided in the Simulink library uses interpolation or extrapolation when computing outputs. This extra accuracy is not needed in all situations. In this example, you will create a lookup table that directly indexes the output vector (y-data vector) based on the current input (x-data) point. This direct 1-D lookup example computes an approximate solution, p(x), to a partially known function f(x) at x=x0, given data point pairs (x,y) in the form of an x data vector and a y data vector. For a given data pair (e.g., the i'th pair), y_i = f(x_i). It is assumed that the x-data values are monotonically increasing. If x0 is outside of the range of the x-data vector, then the first or last point will be returned. The parameters to the S-function are: XData, YData, XEvenlySpaced XData and YData are double vectors of equal length representing the values of the unknown function. XDataEvenlySpaced is a scalar, 0.0 for false and 1.0 for true. If the XData vector is evenly spaced, then more efficient code is generated. 4-21