error using the example script of PCA

조회 수: 1 (최근 30일)
ajith
ajith 2013년 2월 11일
data=imread('result.png');
>> [M,N]=size(data);
>> mn=mean(data,2);
>> data=data-repmat(mn,1,N);
??? Error using ==> minus
Integers can only be combined with integers of the same class, or
scalar doubles.
how to resolve it

답변 (1개)

José-Luis
José-Luis 2013년 2월 11일
편집: José-Luis 2013년 2월 11일
data = imread('result.png');
data = bsxfun(@minus,data,mean(data,2));
Note that this will not solve your problem, as the mean of integers will probably yield doubles. You probably want to do something like:
data = bsxfun(@minus,data,int8(mean(data,2)));
You can find the data type using:
whos data
and you could then modify the application accordingly (change the int8 to the appropiate type). Please accept an answer if it helps you.
  댓글 수: 2
ajith
ajith 2013년 2월 11일
>> data = bsxfun(@minus,data,int8(mean(data,2)));
>> data = data-repmat(mn,1,N);
??? Error using ==> minus Integers can only be combined with integers of the same class, or scalar doubles.
how to resolve it sir
José-Luis
José-Luis 2013년 2월 11일
편집: José-Luis 2013년 2월 11일
It means that mean(data) is not the same type as data. Have you tried what i suggested? What does
whos data
return before you run the script?
Alternatively you could convert everything to double. This should work:
data = double(imread('result.png'));
data = bsxfun(@minus,data,mean(data,2));

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Dimensionality Reduction and Feature Extraction에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by