Overwriting table columns with ()-indexing

Suppose I have two tables,

T1=array2table(rand(5,3))
T2=array2table(char(randi([65,90],5,3)),Var={‘Col1′,’Col2′,’Col3’})

I wish to replace the final column of T1 with that of T2. One way to accomplish this is,
T3=[T1(:,1:2) , T2(:,3) ]
Why, though, does this indexing approach not give the same result?
T3=T1;
T3(:,3)=T2(:,3)
The result is the same as what would be obtained with brace indexing,
T3=T1;
T3{:,3}=T2{:,3}
I understand why brace-indexing gives this result, but I thought ()-indexing was supposed to keep the data contained in a table. Why don’t the tabular properties of T2(:,3), like the column name and data type, get transfered as well when parentheses are used?Suppose I have two tables,

T1=array2table(rand(5,3))
T2=array2table(char(randi([65,90],5,3)),Var={‘Col1′,’Col2′,’Col3’})

I wish to replace the final column of T1 with that of T2. One way to accomplish this is,
T3=[T1(:,1:2) , T2(:,3) ]
Why, though, does this indexing approach not give the same result?
T3=T1;
T3(:,3)=T2(:,3)
The result is the same as what would be obtained with brace indexing,
T3=T1;
T3{:,3}=T2{:,3}
I understand why brace-indexing gives this result, but I thought ()-indexing was supposed to keep the data contained in a table. Why don’t the tabular properties of T2(:,3), like the column name and data type, get transfered as well when parentheses are used? Suppose I have two tables,

T1=array2table(rand(5,3))
T2=array2table(char(randi([65,90],5,3)),Var={‘Col1′,’Col2′,’Col3’})

I wish to replace the final column of T1 with that of T2. One way to accomplish this is,
T3=[T1(:,1:2) , T2(:,3) ]
Why, though, does this indexing approach not give the same result?
T3=T1;
T3(:,3)=T2(:,3)
The result is the same as what would be obtained with brace indexing,
T3=T1;
T3{:,3}=T2{:,3}
I understand why brace-indexing gives this result, but I thought ()-indexing was supposed to keep the data contained in a table. Why don’t the tabular properties of T2(:,3), like the column name and data type, get transfered as well when parentheses are used? table, indexing MATLAB Answers — New Questions

​

Leave a Reply

Your email address will not be published. Required fields are marked *