Home > Blockchain >  Hi, I want to know how to add data to the end of a table in matlab
Hi, I want to know how to add data to the end of a table in matlab

Time:09-29

enter image description here

I want to add another date_time element as well as another cups_out element to the end of this table.

CodePudding user response:

Concatenation works for table arrays. So if you create a table array with the date/time element and cups out that you want to add then you can do,

FinalTable = [CupIntData; AdditionalDataTable];

CodePudding user response:

As well as concatenation, you can also index off the end in the way you would for a regular numeric array. table allows you to provide a cell array, and it knows how to do the right thing:

>> t = table(datetime, 1);
>> t(end 1,:) = {datetime, 2}
t =
  2×2 table
            Var1            Var2
    ____________________    ____
    28-Sep-2022 09:51:56     1  
    28-Sep-2022 09:52:07     2  
  • Related