Why does the inner dimensions of the last line of my code not agree?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Neo
el 11 de En. de 2016
Comentada: Neo
el 11 de En. de 2016
% 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 comentarios
Respuesta aceptada
Image Analyst
el 11 de En. de 2016
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.
Más respuestas (0)
Ver también
Categorías
Más información sobre Operating on Diagonal Matrices en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!