简体   繁体   English

如何在Matlab中绘制矩阵和矩阵的均值?

[英]How to be able to plot Matrix and the mean of matrix in Matlab?

Heiii,, 嘿,

If I have Matrix 如果我有矩阵

 A= n*m 
 and 

 average=mean(A).

How I can possible to plot all the value in matrix (there will be n points) and a Average at the same figure in Matlab?? 如何在Matlab的同一图形上绘制矩阵中的所有值(会有n个点)和一个平均值?

Anyone has the solution?? 有人有解决方案吗?

--------------------- ---------------------

QUESTION


I want to plot my data for PCA. 我想为PCA绘制数据。

For ex/ I have 100*50 matrix. 对于前/我有100 * 50矩阵。

Im now sure, but may be we can consider the column as the feature (feature = 50). 我现在确定,但是也许可以考虑将该列视为特征(特征= 50)。 And for the row, I may be the training data. 对于该行,我可能是训练数据。

So we have 100 training data/image. 因此,我们有100个训练数据/图像。 And I also have mean from my initial matrix. 我的初始矩阵也有平均值。

So, now, Im going to plot each data(100) for every feature (50) and also the mean at the same figure. 因此,现在,我要绘制每个特征(50)的每个数据(100)以及均值。

Here is the example of figure I want to plot .. 这是我要绘制的图的示例..

Can u please help me solve this Master ;) 你能帮我解决这位师父吗;)

The following answer of mine assumes that you have a matrix of nxm . 我的以下答案假定您具有nxm矩阵。 Then you can use 3-D scatter-plot as follows: 然后,您可以如下使用3-D散点图:

%creating all combinations of x and y coordinates
[x,y]=meshgrid(1:size(A,2),1:size(A,1));
x=x(:);
y=y(:);

%plotting values of A such that X-Y axis represent the column and row coordinates of A
%respectively. Z-axis represents the value at that coordinate.
scatter3(x,y,A(:),30,'rx');

%plotting the mean at the center of the coordinate system
hold on;scatter3(mean([1:size(A,2)]),mean([1:size(A,1)]),mean2(A),60,'go','filled');

If it's meaningful to plot each row of A with a different curve (you don't specify how you want to plot A ): 如果有意义的是用不同的曲线绘制A每一行(您无需指定绘制A ):

plot(A.') %'// plot(X) plots the *columns* of X
hold on
plot(mean(A),'k--') %// plot the mean of (the rows of) A

在此处输入图片说明

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

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