フィルターのクリア

Making a string and number matrix

46 ビュー (過去 30 日間)
Yoshi
Yoshi 2016 年 1 月 23 日
コメント済み: jgg 2016 年 1 月 23 日
I am trying to make a matrix which has strings and numbers such as:
a b c d
1 3 4 5
5 6 7 8
9 10 11 12
where a,b,c,d represent a word of sentence with no numerical value, how can I do that?
  1 件のコメント
jgg
jgg 2016 年 1 月 23 日
Do you have a specific purpose for this matrix? For instance, like a table or some data? Because there are specific datatypes which might be useful.
a = [1 5 9]';
b = [3 6 10]';
c = [4 7 8]';
d = [5 8 12]';
T = table(a,b,c,d);
This is convenient since you can call it by name:
T.a
to get th variables and there are a variety of other useful methods (see the documenation).
Alternatively, the most flexible way to just use a cell:
C = cell(4,1)
C{1} = {'a','b','c','d'};
C{2} = [1 3 4 5];
C{3} = [5 6 7 8];
C{4} = [9 10 11 12];

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

採用された回答

Matt J
Matt J 2016 年 1 月 23 日
編集済み: Matt J 2016 年 1 月 23 日
With Cell Arrays, e.g.,
C={'a','b'; 3 , 4}

その他の回答 (0 件)

カテゴリ

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