フィルターのクリア

Why does the inner dimensions of the last line of my code not agree?

1 回表示 (過去 30 日間)
Neo
Neo 2016 年 1 月 11 日
コメント済み: Neo 2016 年 1 月 11 日
% subtract off the mean for each dimension
mn = mean(data,2);
mn2 = mean(data2,2);
data = double(data);
data2 = double(data2);
data = data - mn;
data2 = data2 - mn2;
% calculate the covariance matrix
covariance = cov(data,data2);
%covariance2 = (1 / (N-1)) * (data2'*data2);
% find the eigenvectors and eigenvalues
[PC, V] = eig(covariance);
% [PC2, V2] = eig(covariance2);
% extract diagonal of matrix as vector(so extracting the diagonal of
%the diagonal matrix)
%V = diag(V);
%V2 = diag(V2);
% sort the variances in decreasing order this will allow the PCs to be
% ordered the -1 makes it in descending, otherwise standard is ascending order
%[junk, rindices] = sort(-1*V);
%The value of rindices is the number of columns in V
%V = V(rindices);
%Making a PC matrix
%PC = PC(:,rindices);
% project the original data set
signals = PC * data;
I don't think anything is missing from my calculations and knowledge with PCA, but I get an error because the last line of my code does not allow me to get the signals once I project the zero meaned image on the image matrix that I want the signal of. Can someone explain me why? Cheers - Neo Cornel
  6 件のコメント
Neo
Neo 2016 年 1 月 11 日
It's a bit big, let me know if you can see it now.
Neo
Neo 2016 年 1 月 11 日
編集済み: Neo 2016 年 1 月 11 日
the data matrix is 262441x1 double PC is [1,0;0,1] V is [0,0;0,0]

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

採用された回答

Image Analyst
Image Analyst 2016 年 1 月 11 日
You have:
signals = PC * data;
And PC is 2x2 and data is 262144x1. So you have a matrix multiplication of 2x2*262144x1. The inner dimensions are 2 and 262144 <== those are not the same numbers so you can't do that. Did you see my comment above about the d2 must be the same? Review your algorithm to make sure your equations are correct.
  2 件のコメント
Neo
Neo 2016 年 1 月 11 日
I mean I know that the error was the multiplication, I am asking where did the error occur in the code to make this happen?
Neo
Neo 2016 年 1 月 11 日
The equations are correct and I don't believe I am missing anything so can someone tell me what is it that gives me the error? I should have stated that before accepting the answer.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeEarth, Ocean, and Atmospheric Sciences についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by