필터 지우기
필터 지우기

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 CenterFile Exchange에서 Earth, 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