Error --> Integers can only be combined with in

2019-08-30 08:38发布

问题:

I have the following two matrices:

fuzzySet

255  7  7
255  7  7
255  7  7

membershipMatrix

2.881749158360024e-04   0.999999819474077   0.904200609951489
0.0336048930092375      0.517034652401936   0.847219463816453
2.881749158360024e-04   0.999999819474077   0.904200609951489

When I tried running this code portion:

tolerance = 0.01; 
core = double(fuzzySet.*(abs(membershipMatrix-1) <= tolerance)) + membershipMatrix.*(membershipMatrix.*(abs(membershipMatrix-1) > tolerance););

I got the following error:

??? Error using ==> times
Integers can only be combined with integers of the same class, or scalar doubles.

Error in ==> fs at 36
core = fuzzySet.*(abs(membershipMatrix-1) <= tolerance) +
membershipMatrix.*(membershipMatrix > tolerance);

How can I work around this error?

Thanks.

回答1:

put the double just around fuzzySet?

double(fuzzySet).*(abs(membershipMatrix-1) <= tolerance)