フィルターのクリア

Patients code to text for table

1 回表示 (過去 30 日間)
Luis Eduardo Cofré Lizama
Luis Eduardo Cofré Lizama 2018 年 8 月 20 日
コメント済み: Walter Roberson 2018 年 8 月 31 日
Hi All. Cannot get to read numbers from a matrix and make them into a text to be inserted in a table. The latter to be used in a ranova test. For example.
Injection = [1;1;2;2;3]
Table (1:5,x) = ['Upper_limb', 'Upper_limb','Lower_limb','Lower_limb','Back'];
cheers
Eduardo
  1 件のコメント
Walter Roberson
Walter Roberson 2018 年 8 月 20 日
Is Table intended to be a table() object? Is x intended to be a column number in the table object?
Are you trying to do something like
Injection = [1;1;2;2;3]
Table = table(Injection);
Table(1:5,2) = {'Upper_limb', 'Upper_limb','Lower_limb','Lower_limb','Back'} .';

サインインしてコメントする。

採用された回答

Stephen23
Stephen23 2018 年 8 月 31 日
編集済み: Stephen23 2018 年 8 月 31 日
"Lets say that somewhere in a 630x38 matrix there is a "1". I need a table with the same dimensions but where (place) there is a "1" it will now say "Upper_limb" (text)..... same location as in the matrix."
Where X is your matrix:
C = {'Upper_limb', 'Lower_limb', 'Back'};
X = [1,2,1,3,1]
C(X)

その他の回答 (4 件)

Luis Eduardo Cofré Lizama
Luis Eduardo Cofré Lizama 2018 年 8 月 21 日
編集済み: Walter Roberson 2018 年 8 月 21 日
Thanks Walter, actually more like (probably this is wrong):
for i = 1:5
if Injection (i) == 1
Table (i) == 'Upper_Limb'
elseif Injection (i) == 2
Table (i) == 'Lower_Limb'
end
  1 件のコメント
Walter Roberson
Walter Roberson 2018 年 8 月 21 日
Injection = [1;1;2;2;3]
limbs = {'Upper_limb', 'Upper_limb','Lower_limb','Lower_limb','Back'} .';
Table = limbs(Injection);
See also categorical()

サインインしてコメントする。


Ben Morrow
Ben Morrow 2018 年 8 月 21 日

just re-format before calling it

    %lets say 
      Injection = [1;1;2;2;3]
        %Sort into names that you want
        Upper_limb1 = Injection(1);
        Upper_limb2 = Injection(2);
        Lower_limb1 = Injection(3);
        Lower_limb2 = Injection(4);
        Back = Injection(5);
      injTable = table(Upper_limb1, Upper_limb2,Lower_limb1,Lower_limb2,Back)
    %now just call your table as "injTable" when you need it
%--------------------------------------------------------------
    %now lets say its a row of data...
      Injection = [1,1;1,1;2,2;2,2;3,3]
      Injection = transpose(Injection);
        %Sort into names that you want
        Upper_limb1 = Injection(:,1);
        Upper_limb2 = Injection(:,2);
        Lower_limb1 = Injection(:,3);
        Lower_limb2 = Injection(:,4);
        Back = Injection(:,5);
Table = table(Upper_limb1, Upper_limb2,Lower_limb1,Lower_limb2,Back   
    %now just call "Table" for your column table  
  1 件のコメント
Ben Morrow
Ben Morrow 2018 年 8 月 21 日
just saw walters... that works too

サインインしてコメントする。


Luis Eduardo Cofré Lizama
Luis Eduardo Cofré Lizama 2018 年 8 月 21 日
編集済み: Walter Roberson 2018 年 8 月 21 日
Thanks again, however, I think I am not asking in the right way. The output I need is a column in a table that reads. Also considering I have more than 200 1,2 and 3s to replace, I thought in using a loop.
Column title: Injection site
'Upper_limb';
'Upper_limb';
'Lower_limb';
'Lower_limb';
'Back';
I'll append next to it all the values for all the rest of the variables
  1 件のコメント
Walter Roberson
Walter Roberson 2018 年 8 月 21 日
Injection = [1;1;2;2;3]
limbs = {'Upper_limb', 'Upper_limb','Lower_limb','Lower_limb','Back'} .';
Injection_site = limbs(Injection);
Table = table(Injection_site);

サインインしてコメントする。


Luis Eduardo Cofré Lizama
Luis Eduardo Cofré Lizama 2018 年 8 月 31 日
Maybe I am still not expressing well what I need. Lets say that somewhere in a 630x38 matrix there is a "1". I need a table with the same dimensions but where (place) there is a "1" it will now say "Upper_limb" (text)..... same location as in the matrix.
Cheeeeers

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by