This preview shows pages 1–2. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: % string. The string specifies the name of a field in the structure % array of which you are to find the structure with the minimum value for % this field. You may assume that the given field will only contain % numeric, scalar values. Your function should return first the % structure having the minimum value for the specified field and second % the index of the returned structure. function [ans, loc] = minStruct(A,str) [r c] = size(A) vec = x = 1 y = 1 while x <= r && y <= c vec(x,y) = A(x,y).(str) if x == r x = 1 y = y + 1 else y = y x = x + 1 end end if r > 1 [v c1] = min(min(vec)) m = n = for b = 0:(r-1) n = vec(c1 + (c * b)) m = [m n] end [v, r1] = min(m) ans = A(r1,c1) loc = [r1 c1] else Sheet1 Page 2 [v c1] = min(vec) ans = A(1,c1) loc = c1 end...
View Full Document
This note was uploaded on 07/06/2009 for the course CS 1371 taught by Professor Stallworth during the Fall '08 term at Georgia Institute of Technology.
- Fall '08