I'm new to MatLab and I have a table of a few hundred variables. I know that the smaller variables hold greater significance than the larger variables in that table and want the sparse matrix I graph to illustrate this. Not so much lim approaches 0
but as the lim approaches 1
because I know the most significant values all approach 1. Do I just take the inverse of that matrix?
问问题
120 次
1 回答
2
请注意,这spy
是一种可视化矩阵稀疏模式的方法,但不能让您可视化值。为此,imagesc
是一个很好的候选人。
获得有关该问题的更多信息会有所帮助,但这里有一种方法可以说明接近 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 回答