|
I figured it out.
s = struct('path', {}, 'length', {});
s(1).path = curve1; s(1).length = clength1;
s(2).path = curve2; s(2).length = clength2;
s(3).path = curve3; s(3).length = clength3;
len = s(:).slength;
shortest_path = min(len);
ind = find(min(len));
"Liana" wrote in message <in3lng$b1o$1@fred.mathworks.com>...
> Hello!
>
> Below is a simplified example of what I'm trying to do. So, there is a data structure 's' with three elements s(1), s(2) and s(3). Each element is described by two fields - 'path' and 'length'.
> s(1) = struct('path', {curve1}, 'length', {clength1});
> s(2) = struct('path', {curve2}, 'length', {clength2});
> s(3) = struct('path', {curve3}, 'length', {clength3});
>
> I'd like to find an element AND its index that corresponds to the minimal 'length' value. I'm trying the following but it doesn't work:
> shortest_path = min(s.length);
> Please give an idea of how to do that.
>
> Thanks.
|