Assuming you want to check if a field named myField
in your structure myStruct
contains a certain number (let's say myNumber
), you can use the following code:
main.m165 chars6 lines
The code first checks if the field myField
exists in myStruct
using isfield
function. If the field exists, it checks if any element in the array of myField
values is equal to myNumber
using any
function. If any element is found to be equal to myNumber
, the code displays a message saying that myField
contains myNumber
. Otherwise, it displays a message saying that myField
does not contain myNumber
.
Note that this code assumes that the field myField
contains an array of numbers in the structure myStruct
. If myField
contains a single number instead, you can simplify the code as follows:
main.m158 chars6 lines
gistlibby LogSnag