{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

minStruct - %values from the selected field for x =...

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

View Full Document Right Arrow Icon
function [ind,minu] = minStruct(st,str) %function to find the minimum value within the specified field of the %structure array; return the index of the first structure containing the %minimum value as well as the index value %usage: [ind,min] = minStruct(st,str) if isfield(st,str) a = {st.(str)}; %this will obtain the cell array from that particular field vec = []; %creates an empty vector in order to create a new vector with all of the
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: %values from the selected field for x = 1:length(a) %gets positions 1 through length of a val = a{x}; %obtains the value of a at that particular position vec = [vec val]; %creates a new vector with each loop end ind = find(min(vec)==vec); %finds the position of the minimum value of the new vector minu = min(vec); %finds the actual minimum value of the new vector else ind = ; minu = ; end end e...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online