简体   繁体   English

在Matlab中可视化大量特征向量

[英]Visualize a large number of eigenvectors in Matlab

I have 6 matrices for which I am required to plot the eigenvectors . 我有6个矩阵需要绘制特征向量 These matrices have dimensions from 20x20 to 320x320. 这些矩阵的尺寸从20x20到320x320。 I really do not know what would be the best (clearer) way to plot them. 我真的不知道什么是绘制它们的最佳(更清晰)方式。 Is there any library available to your knowledge? 是否有可用的图书馆? I thought about reducing the dimension of each eigenvector but still, it would be a lot of work. 我曾考虑过减少每个特征向量的维数,但仍然需要大量工作。

N = [40, 80, 160]; % Dimension 1-D grid

% Laplace operators
L1 = -1/((1/N(1))^2) * full( ( spdiags(repmat([1,-2,1], N(1)-1, 1), -1:1, N(1)-1, N(1)-1) ) );
L2 = -1/((1/N(2))^2) * full( ( spdiags(repmat([1,-2,1], N(2)-1, 1), -1:1, N(2)-1, N(2)-1) ) );
L3 = -1/((1/N(3))^2) * full( ( spdiags(repmat([1,-2,1], N(3)-1, 1), -1:1, N(3)-1, N(3)-1) ) );

These matrices are the Laplace operators associated to Poisson's equation. 这些矩阵是与泊松方程相关的拉普拉斯算子。 The aim is to visualize how the eigenvectors change when we change the dimension of the 1D grid I use to solve Poisson's equation. 目的是可视化当我们更改用于求解泊松方程的一维网格的尺寸时特征向量的变化方式。

As you have intuited, we cannot plot them the same way we would plot a 3D vector. 如您所知,我们无法像绘制3D向量一样绘制它们。 If you want to visualize the spacial distance between eigenvectors, you could consider geometry preserving dimensionally reduction like isomap , but the simplest visualization, is to plot the dimensions of the eigenvectors. 如果要可视化特征向量之间的空间距离,则可以考虑像isomap这样保留几何尺寸缩减的几何,但最简单的可视化是绘制特征向量的尺寸。

First, let's get some eigenvectors. 首先,让我们获取一些特征向量。 I use the same example as the eig documentation 我使用与eig文档相同的示例

A = gallery('lehmer',20)
[A_eig_vec, A_eig_val] = eig(A);

Then plot each column as a line. 然后将每列绘制为一条线。 I also use multiple plots to avoid the plots getting too noisy with too many lines. 我还使用多个图来避免由于太多线而导致图变得过于嘈杂。

subplot(4, 1, 1);
plot(A_eig_vec(:, 1:5));

subplot(4, 1, 2);
plot(A_eig_vec(:, 6:10));

subplot(4, 1, 3);
plot(A_eig_vec(:, 11:15));

subplot(4, 1, 4);
plot(A_eig_vec(:, 16:20));

The result looks like this 结果看起来像这样

特征向量图

You can see how the eigenvectors seem to capture different frequencies. 您可以看到特征向量看起来如何捕获不同的频率。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM