Hi Xander,
I am assuming that you have the data you want to insert into the table as 7th column.
For this example we will consider the following structure:
TableName T1 ; Columns: Age,Height,Weight,BloodPressure,LastName
TableName T2 ; Columns: Age,Height,Weight,BloodPressure,LastName
CellArray tableAsCells; Rows: (Table T1); (Table T2)
NewColumn Smoker: {'Yes';'Yes';'Yes';'No';'No'};
There are two approaches to adding a column to an existing table as listed below:
Approach 1: Appending the new column to the pre-existing table:
Step 1: Fetch a Table from the cell array :
>> grabATable = tableAsCells{1};
Step 2: Add column to this table :
>> T1 = [T1, Smoker];
>> T1.Properties.VariableNames(6) = {'Smoker'};
Approach 2: Creating a temporary table and concatenating it to the original table :
Step 1: Fetch a Table from the cell array :
>> grabATable = tableAsCells{1};
Step 2: Add column to this table :
>> newTable = table(Smoker);
>> T1 = [T1,newTable];
Below are the steps to add key and value objects to the Existing container.Map object:
Step 1: Creating new key and Value pairs :
>> newKeyValueSets = {'PlaceHolder1', 'PlaceHolder2', 'PlaceHodler3', 'PlaceHoler4' };
>> newValueSets = {100,110,120,130};
Step 2: Creating a new Map object :
>> newMapObj = containers.Map(newKeyValueSets,newValueSets);
Step 3: Concatenate the two map objects into the original object :
>> mapObj = [mapObj; newMapObj];
More information on concatenating values to map objects can be found in the documentation link below:
Hope this helps.
Thanks
Sudhanshu Bhatt