How can I add a letter to a column of strings. For example i want all names in the column one to change to this Name T.

7 views (last 30 days)
I have one column with many names. I want to add a T to every name. How can I do that?

Accepted Answer

Walter Roberson
Walter Roberson on 6 Oct 2022
%build an example table
sourceletters = 'A':'P';
FirstColumn = string( sourceletters(randi(numel(sourceletters), 5, 7)));
T = table(FirstColumn)
T = 5×1 table
FirstColumn ___________ "MJKGICH" "CDHIOFN" "PKNLFOI" "LDOMKPF" "MNCMDKK"
%now do the work
T.TBefore = "T" + T.FirstColumn;
T.TAfter = T.FirstColumn + "T";
T
T = 5×3 table
FirstColumn TBefore TAfter ___________ __________ __________ "MJKGICH" "TMJKGICH" "MJKGICHT" "CDHIOFN" "TCDHIOFN" "CDHIOFNT" "PKNLFOI" "TPKNLFOI" "PKNLFOIT" "LDOMKPF" "TLDOMKPF" "LDOMKPFT" "MNCMDKK" "TMNCMDKK" "MNCMDKKT"
  4 Comments
Jose Mendoza Garcia
Jose Mendoza Garcia on 6 Oct 2022
I have two tables on matlab. The tables have an identical column 1 and variables. what i want to do is the following:
I want to combine row 1 of table 1 and row 1 of table two. Then i want to do a t test. The tables have 17 columns and i want to do the same for each one. Can you please help me?

Sign in to comment.

More Answers (0)

Categories

Find more on Tables in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!