simulink double value into a logical type error

if true
function y = ratioimg(u)
[L2,num2]=bwlabel(u,8); %連通區域標記
B2=false(size(u));
for i=1:num2
[r,c] = find(L2==i);
left = min(c);
right = max(c);
up = min(r);
down = max(r);
d = (down-up) / (right-left);
if d > 0.7 & d < 1.42
% [x,y]=find(L2==i); % Done above already
B2 = B2 + bwselect(u, c, r, 8); %%%把滿足長寬比在0.8到2的區域留下
end
end
y = B2;
end
i use this function on the simulink but show the error

7 comentarios

Birdman
Birdman el 30 de En. de 2018
Can you share your simulink model?
KAI XUN CAI
KAI XUN CAI el 30 de En. de 2018
this
Birdman
Birdman el 30 de En. de 2018
Editada: Birdman el 30 de En. de 2018
Do you have to do the data type conversion inside a MATLAB Function block?
KAI XUN CAI
KAI XUN CAI el 30 de En. de 2018
no just that code
KAI XUN CAI
KAI XUN CAI el 30 de En. de 2018
so how to conversion?
Birdman
Birdman el 30 de En. de 2018
Which line the conversion will take place? Be more specific.
KAI XUN CAI
KAI XUN CAI el 30 de En. de 2018
B2 = B2 + bwselect(u, c, r, 8); change double

Iniciar sesión para comentar.

Respuestas (1)

Fangjun Jiang
Fangjun Jiang el 30 de En. de 2018
B2 is logical.
B2 = B2 + bwselect(u, c, r, 8)
should be
B2 = or(B2,bwselect(u, c, r, 8))

Preguntada:

el 30 de En. de 2018

Comentada:

el 30 de En. de 2018

Community Treasure Hunt

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

Start Hunting!

Translated by