Da Vinci Firmware 1
Firmware for the DaVinci-M rocket avionics board.
Loading...
Searching...
No Matches
find.h File Reference

Provides MATLAB Coder helper functions to find indices of true values. More...

#include "rtwtypes.h"
#include <stddef.h>
#include <stdlib.h>
Include dependency graph for find.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int b_eml_find (const boolean_T x[5], int i_data[])
 Finds the index of the last true element in a 5-element boolean array.
 
int eml_find (const boolean_T x[6], int i_data[])
 Finds the index of the last true element in a 6-element boolean array.
 

Detailed Description

Provides MATLAB Coder helper functions to find indices of true values.

Author
Francesco Abate, MSA (Originally generated by MATLAB Coder)
Version
24.2 (MATLAB Coder version)
Date
2024-12-03

This auto-generated helper file from MATLAB Coder provides C equivalents of the MATLAB find() command. The functions search a boolean array and return the index of the last element that is true.

These functions are used as low-level utilities by the cdEvaluation function to determine the correct indices for lookup table interpolation within the MPC controller.

Definition in file find.h.

Function Documentation

◆ b_eml_find()

int b_eml_find ( const boolean_T  x[5],
int  i_data[] 
)

Finds the index of the last true element in a 5-element boolean array.

Parameters
[in]xThe 5-element boolean input array to search.
[out]i_dataAn output array where the found index will be stored. The index is 1-based, matching MATLAB's convention.
Returns
The number of true elements found (0 or 1). Returns 0 if no true elements are found, and 1 if at least one is found.

Definition at line 21 of file find.c.

22{
23 int i_size;
24 int idx;
25 int ii;
26 boolean_T exitg1;
27 idx = 0;
28 i_size = 1;
29 ii = 5;
30 exitg1 = false;
31 while ((!exitg1) && (ii > 0)) {
32 if (x[ii - 1]) {
33 idx = 1;
34 i_data[0] = ii;
35 exitg1 = true;
36 } else {
37 ii--;
38 }
39 }
40 if (idx == 0) {
41 i_size = 0;
42 }
43 return i_size;
44}
bool boolean_T
Generic boolean type.
Definition rtwtypes.h:89

Referenced by cdEvaluation().

Here is the caller graph for this function:

◆ eml_find()

int eml_find ( const boolean_T  x[6],
int  i_data[] 
)

Finds the index of the last true element in a 6-element boolean array.

Parameters
[in]xThe 6-element boolean input array to search.
[out]i_dataAn output array where the found index will be stored. The index is 1-based, matching MATLAB's convention.
Returns
The number of true elements found (0 or 1). Returns 0 if no true elements are found, and 1 if at least one is found.

Definition at line 51 of file find.c.

52{
53 int i_size;
54 int idx;
55 int ii;
56 boolean_T exitg1;
57 idx = 0;
58 i_size = 1;
59 ii = 6;
60 exitg1 = false;
61 while ((!exitg1) && (ii > 0)) {
62 if (x[ii - 1]) {
63 idx = 1;
64 i_data[0] = ii;
65 exitg1 = true;
66 } else {
67 ii--;
68 }
69 }
70 if (idx == 0) {
71 i_size = 0;
72 }
73 return i_size;
74}

Referenced by cdEvaluation().

Here is the caller graph for this function: