Dear Coder, I want to rename the the RowNames and VariableNames of a Table. In this case, I have there different table namely, Tab_Eight, Tab_SixLate and Tab_SixEarly. For example, To rename the each of the RowName and VariableName in the Tab_Eight, the following code were realize
% Rename each of the 8 rows
for i=1:8 Tab_Eight.Properties.RowNames{i} = char ((at.sub.ID ((GetPatName(i)),1))); end
And
% To rename each of the 12 column
for i =1:12Tab_Eight.Properties.VariableNames{i} = char ((at.sub.Shiftday ((GetCondType(i)),1)));end
Similarly, the table Tab_SixLate and Tab_SixEarly were modified simply by changing the content in the for loop into Where
For the Tab_SixLatefor i=1:8 Tab_SixLate.Properties.RowNames{i} = char ((at.sub.ID ((GetPatName(i)),1))); end% And
for i =1:12 Tab_SixLate.Properties.VariableNames{i} = char ((at.sub.Shiftday ((GetCondType(i)),1))); endFor the Tab_SixEarlyfor i=1:8 Tab_SixEarly.Properties.RowNames{i} = char ((at.sub.ID ((GetPatName(i)),1))); end% And for i =1:12 Tab_SixEarly.Properties.VariableNames{i} = char ((at.sub.Shiftday ((GetCondType(i)),1))); end
As you can, the code is redundant and I need 6 For loop for the 3 tables. I wonder, how I can minimize the for loops? Note: The code is a portion of the big code. Without lost of meaning, only relevant code were shown
Best Answer