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

1 vue (au cours des 30 derniers jours)
avram alter
avram alter le 2 Mai 2021
Commenté : Image Analyst le 3 Mai 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?

Réponses (1)

Image Analyst
Image Analyst le 2 Mai 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 commentaires
avram alter
avram alter le 3 Mai 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 le 3 Mai 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".

Connectez-vous pour commenter.

Catégories

En savoir plus sur MATLAB dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by