I have arrays and I want to put them in a table

1 view (last 30 days)
I have 9 arrays I want to put them in a table and give them row names and colmn names
My code
Station_1 = [P1;T1;h1] ;
Station_2 = [ P2;T2a;h2a] ;
Station_3 = [ P3a ; T3 ; h3] ;
Station_4 = [ P4a ;T3;h3];
Station_5 = [ P3a;T3;h3];
All these variables have values and want to put them in a table of row names temp pressure enthalpy All arrays together as a table , each array as a colmn and alla together

Answers (1)

James Tursa
James Tursa on 26 Sep 2015
Does this do what you want:
mytable = table(Station_1,Station_2,Station_3,Station_4,Station_5,'RowNames',{'Pressure','Temp','Enthalpy'});
  2 Comments
Kareem AlBokhari
Kareem AlBokhari on 26 Sep 2015
I have R2013a matlab this function is not available any other suggestions
James Tursa
James Tursa on 26 Sep 2015
I suppose you could use a simple cell array:
>> mytable = cell(4,6)
mytable =
[] [] [] [] [] []
[] [] [] [] [] []
[] [] [] [] [] []
[] [] [] [] [] []
>> mytable(1,2:6) = {'Station_1','Station_2','Station_3','Station_4','Station_5'}
mytable =
[] 'Station_1' 'Station_2' 'Station_3' 'Station_4' 'Station_5'
[] [] [] [] [] []
[] [] [] [] [] []
[] [] [] [] [] []
>> mytable(2:4,1) = {'Pressure','Temp','Enthalpy'}'
mytable =
[] 'Station_1' 'Station_2' 'Station_3' 'Station_4' 'Station_5'
'Pressure' [] [] [] [] []
'Temp' [] [] [] [] []
'Enthalpy' [] [] [] [] []
>> mytable(2:4,2:6) = mat2cell([Station_1,Station_2,Station_3,Station_4,Station_5],ones(3,1),ones(1,5))
mytable =
[] 'Station_1' 'Station_2' 'Station_3' 'Station_4' 'Station_5'
'Pressure' [ 0.6948] [ 0.0344] [ 0.7655] [ 0.4898] [ 0.7094]
'Temp' [ 0.3171] [ 0.4387] [ 0.7952] [ 0.4456] [ 0.7547]
'Enthalpy' [ 0.9502] [ 0.3816] [ 0.1869] [ 0.6463] [ 0.2760]
Or maybe something from the FEX. E.g.,

Sign in to comment.

Categories

Find more on Creating and Concatenating Matrices in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!