function DATA=mat2data(data,labels,scales,dlab,title,iidB,iifig)
%
% Call DATA=mat2data(data,labels,scales,dlab,title,iidB,iifig);
%
%
% COPYRIGHT (c) 2008
% 
% Applied Research Laboratories, The University of Texas at Austin
% (ARL:UT)
% All rights reserved.
% 
% This material may be reproduced by or for the U.S. Government
% only. This notice must appear in all copies of this file and its
% derivatives. Further distribution outside the U.S. Government is
% prohibited without the explicit written authorization from the
% Director of the Environmental Sciences Laboratory, ARL:UT.
% 
% THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
% EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO THE
% IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
% PURPOSE, OR NONINFRINGEMENT.
% 
% IN NO EVENT WILL ARL:UT BE LIABLE FOR ANY DAMAGES WHATSOEVER ARISING
% OUT OF THE USE OR INABILITY TO USE THIS SOFTWARE, EVEN IF ARL:UT HAS
% BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
if nargin<1, error('must have at least one input: the data matrix itself'); end
DATA.dims=size(data);
DATA.ndim=length(DATA.dims);
DATA.data=data;
%
if nargin<2 | isempty(labels),
    for jdim=1:DATA.ndim, labels{jdim}=['Dimension ',int2str(jdim)]; end
end
if nargin<3 | isempty(scales),
    for jdim=1:DATA.ndim, scales{jdim}=[1:DATA.dims(jdim)]; end
end
if nargin<4 | isempty(dlab), dlab=' '; end
if nargin<5 | isempty(title), title=' '; end
if nargin<6,
    if all(isreal(data)), iidB=1; else, iidB=-1; end
end
if nargin<7, iifig=1; end
%
DATA.scales=scales;
DATA.labels=labels;
DATA.dlab=dlab;
DATA.title=title;
DATA.iidB=iidB;
if iifig, view5(DATA); end
