フィルターのクリア

Replacing the row and column number with names for a matrix

1 回表示 (過去 30 日間)
Native
Native 2019 年 1 月 18 日
コメント済み: madhan ravi 2019 年 1 月 18 日
I have a matrix 'X' with dimensions 132X132. I want to replace each of these row and column indices with a name derived from a cell arrray 1X132. So, for example if the first cell entry of sol is Area A, I want my the row and column of my matrix to be represented by Area A instead of '1'. This is to ensure i see the area names instead of numbers when I later draw a circular network graph using this matrix.
  2 件のコメント
madhan ravi
madhan ravi 2019 年 1 月 18 日
upload the data as .mat file
Native
Native 2019 年 1 月 18 日
The matrix X here is invfish

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

回答 (1 件)

madhan ravi
madhan ravi 2019 年 1 月 18 日
編集済み: madhan ravi 2019 年 1 月 18 日
one way (as cells) :
X=num2cell(X);
X(1,:)=Names(1,:) % result as cells
% ^^^^^^^^^^------ 1 X 132 cell array containing names
second way (as table):
X=num2cell(X);
T=cell2table(X);
T.Properties.VariableNames=Names % result as table , nicer and organised
  2 件のコメント
Native
Native 2019 年 1 月 18 日
it is creating nested cells in the table insteadof what I want
madhan ravi
madhan ravi 2019 年 1 月 18 日
That is the only way , how do you want it ?

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

カテゴリ

Help Center および File ExchangeMultidimensional Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by