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.

4 vues (au cours des 30 derniers jours)
I have one column with many names. I want to add a T to every name. How can I do that?

Réponse acceptée

Walter Roberson
Walter Roberson le 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 commentaires
Jose Mendoza Garcia
Jose Mendoza Garcia le 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?

Connectez-vous pour commenter.

Plus de réponses (0)

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by