Borrar filtros
Borrar filtros

operand (&&) error when trying to set a parameter

1 visualización (últimos 30 días)
avram alter
avram alter el 2 de Mayo de 2021
Comentada: Image Analyst el 3 de Mayo de 2021
I have a block of code that evaluates one matrix, BOX, with anohter matrix, TruveValMat. each of these has 8 values that need to be compared, when they all come back as equal, it enables a button on a GUI:
if strcmp(TrueValMat{1,1}, BOX(1,:)...
&& strcmp(TrueValMat{1,2}, BOX(2,:))...
&& strcmp(TrueValMat{1,3}, BOX(3,:))...
&& strcmp(TrueValMat{1,4}, BOX(4,:))...
&& strcmp(TrueValMat{1,5}, BOX(5,:))...
&& strcmp(TrueValMat{1,6}, BOX(6,:))...
&& strcmp(TrueValMat{1,7}, BOX(7,:))...
&& strcmp(TrueValMat{1,8}, BOX(8,:)))
set(handles.certifyButton, 'enable', 'on');
I am now getting this error when I run I get up to this part:
Operands to the logical and (&&) and or (||) operators must be convertible to logical scalar values.
is there any way to fix this error?

Respuestas (1)

Image Analyst
Image Analyst el 2 de Mayo de 2021
Simply use isequal():
if isequal(TrueValMat, BOX)
handles.certifyButton.Enable = 'on'; % Using new and modern OOP way instead of old set() way.
end
  2 comentarios
avram alter
avram alter el 3 de Mayo de 2021
I have an indicator that occurs when each position in BOX becomes equal to the position in TruveValMat. it looks like this:
if strcmp(TrueValMat{1,n}, BOX(n,:)) %cannot sub-index to CELL types normally, must use this method
set(handles.Box(n), 'BackgroundColor', 'g');
else
set(handles.Box(n), 'BackgroundColor', 'r');
end
Box is the name of panel that corresponds to each value of BOX. when all of the panels turn green, that would mean that BOX = TruevalMa at each position. however, despite each box going green, the certify button does not get enabled, whether I use the new OOP method or the old one
Image Analyst
Image Analyst el 3 de Mayo de 2021
Please attach TrueValMat, BOX in a .mat file so people can try things.
save('answers.mat', 'TrueValMat', 'BOX');
Attach a screenshot of your "indicator".

Iniciar sesión para comentar.

Categorías

Más información sobre MATLAB en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by