yakkisyou
yakkisyou

Reputation: 520

matlab - function strel input type error

When I try se = strel('square', 2.4);, this error occurs:

??? Error using ==> iptcheckinput
Function STREL expected its second input, SIZE, to be integer-valued.

Error in ==> strel>ParseInputs at 1154
        iptcheckinput(M, {'double'}, {'scalar' 'integer' 'real' 'nonnegative'}, ...

Error in ==> strel>strel.strel at 146
                [type,params] = ParseInputs(varargin{:});

So, I changed the input value 2.4 to int8(2.4), then another error occurs:

??? Error using ==> iptcheckinput
Function STREL expected its second input, SIZE,
to be one of these types:

  double

Instead its type was int8.

Error in ==> strel>ParseInputs at 1154
        iptcheckinput(M, {'double'}, {'scalar' 'integer' 'real' 'nonnegative'}, ...

Error in ==> strel>strel.strel at 146
                [type,params] = ParseInputs(varargin{:});

I think 2.4 is double type and int8(2.4) is integer, doesn't it?

So I can't understand those errors.

I want strel('square', 2.4) to be strel('square', 2).

What should I do? What does that error means?

Upvotes: 0

Views: 280

Answers (1)

OmG
OmG

Reputation: 18838

to change 2.4 to 2 you can use fix function. For example:

fix(2.4) == 2 // true

So, write the code likes the following:

 strel('square', fix(2.4))

Upvotes: 2

Related Questions