rows2varsFS calls rows2vars but the the names of the cols of the original table become rownames
MATLAB function rows2vars transforms T1 of size n-by-p into T2 of size p-by-(n+1). The first column of T2 is called OriginalVariableNames and contains the names of the table variables from T1 and the RowNames of T2 are empty. FSDA function rows2varsFS transforms T1 of size n-by-p into T2 of size p-by-n. The names of the variables of T1 become the names of the rows of T2. For example, if T1 has two rows and five columns, after the call T2=rows2varsFS(T1) has five rows and 5 columns.
The RowNames of T2 are the original variable names of T1 and viceversa.
Example with RowNames in the original table.T2
=rows2varsFS(T1,
Name, Value)
 rows2varsFS with all default options.
load patients
T1 = table(LastName,Gender,Age,Height,Weight);
disp('Original table (first 5 rows)')
disp(head(T1,5))
disp('Output of rows2vars (first 5 columns)')
T2=rows2vars(T1)
disp(head(T2(:,1:5)))
disp('Output of rows2varsFS (first 5 columns)')
T2fs=rows2varsFS(T1);
disp(head(T2fs(:,1:5)))Original table (first 5 rows)
      LastName        Gender      Age    Height    Weight
    ____________    __________    ___    ______    ______
    {'Smith'   }    {'Male'  }    38       71       176  
    {'Johnson' }    {'Male'  }    43       69       163  
    {'Williams'}    {'Female'}    38       64       131  
    {'Jones'   }    {'Female'}    40       67       133  
    {'Brown'   }    {'Female'}    49       64       119  
Output of rows2vars (first 5 columns)
T2 =
  5×101 table
    OriginalVariableNames      Var1          Var2            Var3           Var4          Var5          Var6          Var7          Var8         Var9         Var10          Var11          Var12          Var13         Var14        Var15         Var16          Var17          Var18          Var19           Var20          Var21           Var22          Var23         Var24         Var25        Var26        Var27         Var28           Var29         Var30        Var31         Var32         Var33         Var34        Var35        Var36         Var37         Var38          Var39         Var40          Var41          Var42         Var43         Var44          Var45           Var46          Var47         Var48          Var49          Var50          Var51          Var52         Var53         Var54        Var55        Var56         Var57        Var58        Var59         Var60         Var61         Var62           Var63           Var64         Var65        Var66        Var67          Var68          Var69          Var70         Var71        Var72         Var73         Var74          Var75         Var76         Var77        Var78        Var79         Var80           Var81           Var82          Var83         Var84         Var85        Var86          Var87          Var88         Var89           Var90           Var91          Var92         Var93          Var94          Var95           Var96           Var97          Var98        Var99       Var100  
    _____________________    _________    ___________    ____________    __________    __________    __________    __________    __________    _________    __________    ____________    __________    ___________    _________    __________    __________    ____________    __________    ____________    ____________    __________    _____________    __________    __________    __________    ________    __________    __________    _____________    ________    __________    __________    __________    _________    _________    __________    _________    ____________    __________    __________    ____________    _________    ___________    __________    ____________    ____________    __________    __________    ___________    ___________    ___________    ___________    __________    __________    ________    __________    __________    ________    __________    __________    __________    __________    ______________    __________    __________    ________    __________    ____________    __________    ___________    _________    __________    __________    __________    ___________    _________    ___________    ________    __________    __________    _____________    ___________    ___________    __________    __________    ________    _____________    __________    __________    ______________    __________    ___________    __________    ____________    __________    _____________    ___________    ___________    ________    _________
        {'LastName'}         {'Smith'}    {'Johnson'}    {'Williams'}    {'Jones' }    {'Brown' }    {'Davis' }    {'Miller'}    {'Wilson'}    {'Moore'}    {'Taylor'}    {'Anderson'}    {'Thomas'}    {'Jackson'}    {'White'}    {'Harris'}    {'Martin'}    {'Thompson'}    {'Garcia'}    {'Martinez'}    {'Robinson'}    {'Clark' }    {'Rodriguez'}    {'Lewis' }    {'Lee'   }    {'Walker'}    {'Hall'}    {'Allen' }    {'Young' }    {'Hernandez'}    {'King'}    {'Wright'}    {'Lopez' }    {'Hill'  }    {'Scott'}    {'Green'}    {'Adams' }    {'Baker'}    {'Gonzalez'}    {'Nelson'}    {'Carter'}    {'Mitchell'}    {'Perez'}    {'Roberts'}    {'Turner'}    {'Phillips'}    {'Campbell'}    {'Parker'}    {'Evans' }    {'Edwards'}    {'Collins'}    {'Stewart'}    {'Sanchez'}    {'Morris'}    {'Rogers'}    {'Reed'}    {'Cook'  }    {'Morgan'}    {'Bell'}    {'Murphy'}    {'Bailey'}    {'Rivera'}    {'Cooper'}    {'Richardson'}    {'Cox'   }    {'Howard'}    {'Ward'}    {'Torres'}    {'Peterson'}    {'Gray'  }    {'Ramirez'}    {'James'}    {'Watson'}    {'Brooks'}    {'Kelly' }    {'Sanders'}    {'Price'}    {'Bennett'}    {'Wood'}    {'Barnes'}    {'Ross'  }    {'Henderson'}    {'Coleman'}    {'Jenkins'}    {'Perry' }    {'Powell'}    {'Long'}    {'Patterson'}    {'Hughes'}    {'Flores'}    {'Washington'}    {'Butler'}    {'Simmons'}    {'Foster'}    {'Gonzales'}    {'Bryant'}    {'Alexander'}    {'Russell'}    {'Griffin'}    {'Diaz'}    {'Hayes'}
        {'Gender'  }         {'Male' }    {'Male'   }    {'Female'  }    {'Female'}    {'Female'}    {'Female'}    {'Female'}    {'Male'  }    {'Male' }    {'Female'}    {'Female'  }    {'Female'}    {'Male'   }    {'Male' }    {'Female'}    {'Male'  }    {'Male'    }    {'Female'}    {'Male'    }    {'Male'    }    {'Female'}    {'Female'   }    {'Female'}    {'Female'}    {'Female'}    {'Male'}    {'Female'}    {'Female'}    {'Male'     }    {'Male'}    {'Female'}    {'Female'}    {'Female'}    {'Male' }    {'Male' }    {'Female'}    {'Male' }    {'Female'  }    {'Male'  }    {'Female'}    {'Male'    }    {'Male' }    {'Male'   }    {'Male'  }    {'Male'    }    {'Female'  }    {'Male'  }    {'Female'}    {'Male'   }    {'Male'   }    {'Male'   }    {'Female' }    {'Female'}    {'Female'}    {'Male'}    {'Female'}    {'Female'}    {'Male'}    {'Male'  }    {'Female'}    {'Female'}    {'Female'}    {'Female'    }    {'Female'}    {'Female'}    {'Male'}    {'Female'}    {'Female'  }    {'Female'}    {'Female' }    {'Male' }    {'Female'}    {'Male'  }    {'Female'}    {'Female' }    {'Male' }    {'Female' }    {'Male'}    {'Male'  }    {'Female'}    {'Male'     }    {'Male'   }    {'Male'   }    {'Female'}    {'Female'}    {'Male'}    {'Female'   }    {'Female'}    {'Female'}    {'Female'    }    {'Male'  }    {'Male'   }    {'Female'}    {'Male'    }    {'Female'}    {'Male'     }    {'Male'   }    {'Male'   }    {'Male'}    {'Male' }
        {'Age'     }         {[   38]}    {[     43]}    {[      38]}    {[    40]}    {[    49]}    {[    46]}    {[    33]}    {[    40]}    {[   28]}    {[    31]}    {[      45]}    {[    42]}    {[     25]}    {[   39]}    {[    36]}    {[    48]}    {[      32]}    {[    27]}    {[      37]}    {[      50]}    {[    48]}    {[       39]}    {[    41]}    {[    44]}    {[    28]}    {[  25]}    {[    39]}    {[    25]}    {[       36]}    {[  30]}    {[    45]}    {[    40]}    {[    25]}    {[   47]}    {[   44]}    {[    48]}    {[   44]}    {[      35]}    {[    33]}    {[    38]}    {[      39]}    {[   44]}    {[     44]}    {[    37]}    {[      45]}    {[      37]}    {[    30]}    {[    39]}    {[     42]}    {[     42]}    {[     49]}    {[     44]}    {[    43]}    {[    47]}    {[  50]}    {[    38]}    {[    41]}    {[  45]}    {[    36]}    {[    38]}    {[    29]}    {[    28]}    {[        30]}    {[    28]}    {[    29]}    {[  36]}    {[    45]}    {[      32]}    {[    31]}    {[     48]}    {[   25]}    {[    40]}    {[    39]}    {[    41]}    {[     33]}    {[   31]}    {[     35]}    {[  32]}    {[    42]}    {[    48]}    {[       34]}    {[     39]}    {[     28]}    {[    29]}    {[    32]}    {[  39]}    {[       37]}    {[    49]}    {[    31]}    {[        37]}    {[    38]}    {[     45]}    {[    30]}    {[      48]}    {[    48]}    {[       25]}    {[     44]}    {[     49]}    {[  45]}    {[   48]}
        {'Height'  }         {[   71]}    {[     69]}    {[      64]}    {[    67]}    {[    64]}    {[    68]}    {[    64]}    {[    68]}    {[   68]}    {[    66]}    {[      68]}    {[    66]}    {[     71]}    {[   72]}    {[    65]}    {[    71]}    {[      69]}    {[    69]}    {[      70]}    {[      68]}    {[    65]}    {[       64]}    {[    62]}    {[    66]}    {[    65]}    {[  70]}    {[    63]}    {[    63]}    {[       68]}    {[  67]}    {[    70]}    {[    66]}    {[    64]}    {[   70]}    {[   71]}    {[    66]}    {[   71]}    {[      66]}    {[    66]}    {[    63]}    {[      71]}    {[   69]}    {[     70]}    {[    70]}    {[      67]}    {[      65]}    {[    68]}    {[    62]}    {[     70]}    {[     67]}    {[     68]}    {[     62]}    {[    64]}    {[    66]}    {[  72]}    {[    63]}    {[    66]}    {[  70]}    {[    71]}    {[    68]}    {[    63]}    {[    65]}    {[        67]}    {[    66]}    {[    68]}    {[  71]}    {[    70]}    {[      60]}    {[    64]}    {[     64]}    {[   66]}    {[    64]}    {[    72]}    {[    65]}    {[     67]}    {[   72]}    {[     64]}    {[  68]}    {[    66]}    {[    64]}    {[       68]}    {[     69]}    {[     69]}    {[    64]}    {[    63]}    {[  68]}    {[       65]}    {[    63]}    {[    66]}    {[        65]}    {[    68]}    {[     71]}    {[    70]}    {[      71]}    {[    66]}    {[       69]}    {[     69]}    {[     70]}    {[  68]}    {[   66]}
        {'Weight'  }         {[  176]}    {[    163]}    {[     131]}    {[   133]}    {[   119]}    {[   142]}    {[   142]}    {[   180]}    {[  183]}    {[   132]}    {[     128]}    {[   137]}    {[    174]}    {[  202]}    {[   129]}    {[   181]}    {[     191]}    {[   131]}    {[     179]}    {[     172]}    {[   133]}    {[      117]}    {[   137]}    {[   146]}    {[   123]}    {[ 189]}    {[   143]}    {[   114]}    {[      166]}    {[ 186]}    {[   126]}    {[   137]}    {[   138]}    {[  187]}    {[  193]}    {[   137]}    {[  192]}    {[     118]}    {[   180]}    {[   128]}    {[     164]}    {[  183]}    {[    169]}    {[   194]}    {[     172]}    {[     135]}    {[   182]}    {[   121]}    {[    158]}    {[    179]}    {[    170]}    {[    136]}    {[   135]}    {[   147]}    {[ 186]}    {[   124]}    {[   134]}    {[ 170]}    {[   180]}    {[   130]}    {[   130]}    {[   127]}    {[       141]}    {[   111]}    {[   134]}    {[ 189]}    {[   137]}    {[     136]}    {[   130]}    {[    137]}    {[  186]}    {[   127]}    {[   176]}    {[   127]}    {[    115]}    {[  178]}    {[    131]}    {[ 183]}    {[   194]}    {[   126]}    {[      186]}    {[    188]}    {[    189]}    {[   120]}    {[   132]}    {[ 182]}    {[      120]}    {[   123]}    {[   141]}    {[       129]}    {[   184]}    {[    181]}    {[   124]}    {[     174]}    {[   134]}    {[      171]}    {[    188]}    {[    186]}    {[ 172]}    {[  177]}
    OriginalVariableNames      Var1          Var2            Var3           Var4   
    _____________________    _________    ___________    ____________    __________
        {'LastName'}         {'Smith'}    {'Johnson'}    {'Williams'}    {'Jones' }
        {'Gender'  }         {'Male' }    {'Male'   }    {'Female'  }    {'Female'}
        {'Age'     }         {[   38]}    {[     43]}    {[      38]}    {[    40]}
        {'Height'  }         {[   71]}    {[     69]}    {[      64]}    {[    67]}
        {'Weight'  }         {[  176]}    {[    163]}    {[     131]}    {[   133]}
Output of rows2varsFS (first 5 columns)
                  Var1          Var2            Var3           Var4          Var5   
                _________    ___________    ____________    __________    __________
    LastName    {'Smith'}    {'Johnson'}    {'Williams'}    {'Jones' }    {'Brown' }
    Gender      {'Male' }    {'Male'   }    {'Female'  }    {'Female'}    {'Female'}
    Age         {[   38]}    {[     43]}    {[      38]}    {[    40]}    {[    49]}
    Height      {[   71]}    {[     69]}    {[      64]}    {[    67]}    {[    64]}
    Weight      {[  176]}    {[    163]}    {[     131]}    {[   133]}    {[   119]}
 Example with RowNames in the original table.
load patients
T1 = table(Gender,Age,Height,Weight,'RowNames',LastName);
disp('Original table (first 5 rows)')
head(T1,5)
T2=rows2vars(T1);
disp('Output of rows2vars (first 5 columns)')
disp(head(T2(:,1:5)))
disp('Output of rows2varsFS (first 5 columns)')
T2fs=rows2varsFS(T1);
disp(head(T2fs(:,1:5)))Original table (first 5 rows)
                  Gender      Age    Height    Weight
                __________    ___    ______    ______
    Smith       {'Male'  }    38       71       176  
    Johnson     {'Male'  }    43       69       163  
    Williams    {'Female'}    38       64       131  
    Jones       {'Female'}    40       67       133  
    Brown       {'Female'}    49       64       119  
Output of rows2vars (first 5 columns)
    OriginalVariableNames     Smith      Johnson      Williams       Jones   
    _____________________    ________    ________    __________    __________
         {'Gender'}          {'Male'}    {'Male'}    {'Female'}    {'Female'}
         {'Age'   }          {[  38]}    {[  43]}    {[    38]}    {[    40]}
         {'Height'}          {[  71]}    {[  69]}    {[    64]}    {[    67]}
         {'Weight'}          {[ 176]}    {[ 163]}    {[   131]}    {[   133]}
Output of rows2varsFS (first 5 columns)
               Smith      Johnson      Williams       Jones         Brown   
              ________    ________    __________    __________    __________
    Gender    {'Male'}    {'Male'}    {'Female'}    {'Female'}    {'Female'}
    Age       {[  38]}    {[  43]}    {[    38]}    {[    40]}    {[    49]}
    Height    {[  71]}    {[  69]}    {[    64]}    {[    67]}    {[    64]}
    Weight    {[ 176]}    {[ 163]}    {[   131]}    {[   133]}    {[   119]}
 Example of use of option "DataVariables".
load patients
T1 = table(Gender,Age,Height,Weight,'RowNames',LastName);
disp('Original table (first 5 rows)')
head(T1,5)
disp('Output of rows2vars (first 5 columns)')
T2=rows2vars(T1,'DataVariables',["Gender" "Age"]);
disp(head(T2(:,1:5)))
disp('Output of rows2varsFS ')
T2fs=rows2varsFS(T1,'DataVariables',["Gender" "Age"]);
disp(head(T2fs(:,1:5)))Original table (first 5 rows)
                  Gender      Age    Height    Weight
                __________    ___    ______    ______
    Smith       {'Male'  }    38       71       176  
    Johnson     {'Male'  }    43       69       163  
    Williams    {'Female'}    38       64       131  
    Jones       {'Female'}    40       67       133  
    Brown       {'Female'}    49       64       119  
Output of rows2vars (first 5 columns)
    OriginalVariableNames     Smith      Johnson      Williams       Jones   
    _____________________    ________    ________    __________    __________
         {'Gender'}          {'Male'}    {'Male'}    {'Female'}    {'Female'}
         {'Age'   }          {[  38]}    {[  43]}    {[    38]}    {[    40]}
Output of rows2varsFS 
               Smith      Johnson      Williams       Jones         Brown   
              ________    ________    __________    __________    __________
    Gender    {'Male'}    {'Male'}    {'Female'}    {'Female'}    {'Female'}
    Age       {[  38]}    {[  43]}    {[    38]}    {[    40]}    {[    49]}
 Example of use of option "VariableNamesSource".
T1 = readtable('patients.xls');
disp('Original table (first 5 rows)')
head(T1,5)
T2=rows2vars(T1,'VariableNamesSource','LastName');
disp('Output of rows2vars (first 5 columns)')
disp(head(T2(:,1:5)))
disp('Output of rows2varsFS (first 5 columns)')
T2fs=rows2varsFS(T1,'VariableNamesSource','LastName');
disp(head(T2fs(:,1:5)))Original table (first 5 rows)
      LastName        Gender      Age              Location               Height    Weight    Smoker    Systolic    Diastolic    SelfAssessedHealthStatus
    ____________    __________    ___    _____________________________    ______    ______    ______    ________    _________    ________________________
    {'Smith'   }    {'Male'  }    38     {'County General Hospital'  }      71       176      true        124          93             {'Excellent'}      
    {'Johnson' }    {'Male'  }    43     {'VA Hospital'              }      69       163      false       109          77             {'Fair'     }      
    {'Williams'}    {'Female'}    38     {'St. Mary's Medical Center'}      64       131      false       125          83             {'Good'     }      
    {'Jones'   }    {'Female'}    40     {'VA Hospital'              }      67       133      false       117          75             {'Fair'     }      
    {'Brown'   }    {'Female'}    49     {'County General Hospital'  }      64       119      false       122          80             {'Good'     }      
Output of rows2vars (first 5 columns)
    OriginalVariableNames               Smith                   Johnson                  Williams                    Jones     
    _____________________    ___________________________    _______________    _____________________________    _______________
        {'Gender'   }        {'Male'                   }    {'Male'       }    {'Female'                   }    {'Female'     }
        {'Age'      }        {[                     38]}    {[         43]}    {[                       38]}    {[         40]}
        {'Location' }        {'County General Hospital'}    {'VA Hospital'}    {'St. Mary's Medical Center'}    {'VA Hospital'}
        {'Height'   }        {[                     71]}    {[         69]}    {[                       64]}    {[         67]}
        {'Weight'   }        {[                    176]}    {[        163]}    {[                      131]}    {[        133]}
        {'Smoker'   }        {[                      1]}    {[          0]}    {[                        0]}    {[          0]}
        {'Systolic' }        {[                    124]}    {[        109]}    {[                      125]}    {[        117]}
        {'Diastolic'}        {[                     93]}    {[         77]}    {[                       83]}    {[         75]}
Output of rows2varsFS (first 5 columns)
                            Smith                   Johnson                  Williams                    Jones                    Brown           
                 ___________________________    _______________    _____________________________    _______________    ___________________________
    Gender       {'Male'                   }    {'Male'       }    {'Female'                   }    {'Female'     }    {'Female'                 }
    Age          {[                     38]}    {[         43]}    {[                       38]}    {[         40]}    {[                     49]}
    Location     {'County General Hospital'}    {'VA Hospital'}    {'St. Mary's Medical Center'}    {'VA Hospital'}    {'County General Hospital'}
    Height       {[                     71]}    {[         69]}    {[                       64]}    {[         67]}    {[                     64]}
    Weight       {[                    176]}    {[        163]}    {[                      131]}    {[        133]}    {[                    119]}
    Smoker       {[                      1]}    {[          0]}    {[                        0]}    {[          0]}    {[                      0]}
    Systolic     {[                    124]}    {[        109]}    {[                      125]}    {[        117]}    {[                    122]}
    Diastolic    {[                     93]}    {[         77]}    {[                       83]}    {[         75]}    {[                     80]}
 Example of use of option 'VariableNamingRule'.
nam={'Temp' 'WindSpeed' 'Rain'};  
BB=[59.5000    0.1000    0.0500
63.0000    2.3000    0.0800
61.7000    3.1000    0.1300
55.4000    5.7000    0.1500
62.3000    2.6000    0.8700
58.8000    6.2000    0.3300];
T1= array2timetable(BB,'VariableNames',nam,'RowTimes',datetime(2024,4,1:6));
disp('Original table (first 5 rows)')
head(T1,5)
T2=rows2vars(T1,'VariableNamingRule','preserve');
disp('Output of rows2vars (first 5 columns)')
disp(head(T2(:,1:5)))
disp('Output of rows2varsFS (first 5 columns)')
T2fs=rows2varsFS(T1,'VariableNamingRule','preserve');
disp(head(T2fs(:,1:5)))Original table (first 5 rows)
       Time        Temp    WindSpeed    Rain
    ___________    ____    _________    ____
    01-Apr-2024    59.5       0.1       0.05
    02-Apr-2024      63       2.3       0.08
    03-Apr-2024    61.7       3.1       0.13
    04-Apr-2024    55.4       5.7       0.15
    05-Apr-2024    62.3       2.6       0.87
Output of rows2vars (first 5 columns)
    OriginalVariableNames    01-Apr-2024    02-Apr-2024    03-Apr-2024    04-Apr-2024
    _____________________    ___________    ___________    ___________    ___________
        {'Temp'     }           59.5             63           61.7           55.4    
        {'WindSpeed'}            0.1            2.3            3.1            5.7    
        {'Rain'     }           0.05           0.08           0.13           0.15    
Output of rows2varsFS (first 5 columns)
                 01-Apr-2024    02-Apr-2024    03-Apr-2024    04-Apr-2024    05-Apr-2024
                 ___________    ___________    ___________    ___________    ___________
    Temp            59.5             63           61.7           55.4           62.3    
    WindSpeed        0.1            2.3            3.1            5.7            2.6    
    Rain            0.05           0.08           0.13           0.15           0.87    
T1 — Origianal table.  
 table or timetable.Input table, specified as a table or timetable of size n-by-p.
 Data Types: single| double
Specify optional comma-separated pairs of Name,Value arguments.
 Name is the argument name and Value
 is the corresponding value. Name must appear 
 inside single quotes (' '). 
 You can specify several name and value pair arguments in any order as  
 Name1,Value1,...,NameN,ValueN.
 'bonflev',0.99
, 'VariableNamingRule','preserve'
DataVariables 
—Selected variables from T1.string array | character vector.Indication of the variables that have to be reoriented.
See help of rows2vars for additional details
       Example:  'bonflev',0.99
Data Types: string array | character vector | cell array of character vectors | pattern scalar | positive integer | vector of positive integers | logical vector
VariableNamingRule 
—Rule for naming variables in T2.|             modify' (default) | 'preserve'.See help of rows2vars for additional details
       Example:  'VariableNamingRule','preserve'
Data Types: string  | char
T2 —table with p rows and n columns.
Where p is the number of columns of T1
                or length(DataVariables)n is the number of rows of the input table.
The RowNames of T2 are the VariableNames of T1 the VariableNames specified in DataVariables