findInStruct - which the value was found If no structure is...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
function [outstr index] = findInStruct(str,field,value) % Usage: [outstr index] = findInStruct(str,field,value) % % findInStruct takes in a structure array, a fieldname as a string, and a % value to look for in that fieldname in the structure array. findInStruct % will return the first structure containing that value and the index at
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: % which the value was found. If no structure is found, an empty structure % and index of 0 will be returned. % for i = 1:length(str) foundat(i) = isequal(str(i).(field),value); end outstr = str(foundat); index = find(foundat); if isempty(index) index = 0; end...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online