0

私はMatLabが初めてで、数百の変数のテーブルがあります。その表では、小さな変数が大きな変数よりも大きな意味を持つことを知っており、これをグラフ化した疎行列で示したいと思います。それほど多くはありませんlim approaches 0lim approaches 1、最も重要な値がすべて 1 に近づくことがわかっているためです。その行列の逆数を取るだけですか?

4

1 に答える 1

2

これspyは行列のスパース パターンを視覚化する方法ですが、値を視覚化することはできません。そのためにimagescは、良い候補です。

問題についてより多くの情報があると役立ちますが、1 に近い値の重要性を示す 1 つの方法を次に示します。

% Generate a random 10x10 matrix with 50% sparsity in [0,9]
x = 9*sprand(10,10,0.5);
% Add 1 to non-zero elements so they are in the range [1,10]
x = spfun(@(a) a+1, x);
% Visualize this matrix
figure(1); imagesc(x); colorbar; colormap('gray');

% Create the "importance matrix", which inverts non-zero values.
% The non-zero elements will now be in the range [1/10,1]
y = spfun(@(a) 1./a, x);
% Visualize this matrix
figure(2); imagesc(y); colorbar; colormap('gray');

コメントに対処するために編集:

% If you want to see values that are exactly 1, you can use
y = spfun(@(a) a==1, x);
% If you want the inverse distance from 1, use
y = spfun(@(a) 1./(abs(a-1)+1), x);
于 2015-08-25T02:39:44.933 に答える