function [values,names] = getfields(s)
% [values,names] = getfields(s)
%   s is structure

values = [];
names = {};

fields = fieldnames(s);
for f = fields'
  cf = char(f);
  names = {names{:} cf};
  value = getfield(s,cf);
  if ~(iscell(value) || prod(size(value)) > 1 || isempty(value))
    values = [values value];
  else
    values = [values NaN];
  end
end
