Assuming you have a structure array, you could use a for loop with conditional statements to search for a specific number. Here is an example code:
main.m427 chars18 lines
This code will loop through the structure array s
, and check if the field1
value of each struct matches the number_to_find
. If a match is found, it will display the index of that struct in the array (in this case, it would display "Number found in structure at index 2", since s(2).field1
is equal to number_to_find
).
gistlibby LogSnag