Home > atmlab > math > vec2row.m

vec2row

PURPOSE ^

VEC2ROW Ensures that a variable not has less columns than rows.

SYNOPSIS ^

function v = vec2row(v)

DESCRIPTION ^

 VEC2ROW   Ensures that a variable not has less columns than rows.

    The most common application of this function is to ensure that a 
    vector is a row vector.

 FORMAT   v = vec2row(v)
        
 OUT   v   A variable of any type.
 IN    v   The variable possible transposed.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

vec2row.m

SOURCE CODE ^

0001 % VEC2ROW   Ensures that a variable not has less columns than rows.
0002 %
0003 %    The most common application of this function is to ensure that a
0004 %    vector is a row vector.
0005 %
0006 % FORMAT   v = vec2row(v)
0007 %
0008 % OUT   v   A variable of any type.
0009 % IN    v   The variable possible transposed.
0010 
0011 % 1993        Created by Patrick Eriksson.
0012 % 2002-12-10  Adapted to Atmlab from arts/ami.
0013 % 2013-03-04  Bugfix by Gerrit Holl for empty vector + do not get conj
0014 
0015 function v = vec2row(v)
0016 
0017 wid = ['atmlab:' mfilename ':zero'];
0018 [rows,cols] = size(v);
0019 
0020 if all(size(v)==0)
0021     warning(wid, 'Cannot convert zero-sized vector to row');
0022 end
0023 
0024 if (isempty(v) && ~isrow(v)) || (~isempty(v) && rows > cols)
0025  v = v.';
0026 end
0027 end

Generated on Mon 15-Sep-2014 13:31:28 by m2html © 2005