operands to the and && operators must be convertible to logical scalar values. This error appears in app designer. Why does this happen?
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
function NextButtonPushed(app, event)
global DD MM Y
opts = 'non-modal';
year = num2str(Y);
ycheck1 = floor(Y/4);
ycheck2 = floor(Y/100);
ycheck3 = floor(Y/400);
if ((DD > 29) && (MM == 2))
errordlg('February has 29 days max', 'Error!', opts);
error('Error occurred!');
end
if ((ycheck2 == Y/100) && (ycheck3 ~= Y/400) && (DD == 29) && (MM == 2))
errordlg(['Year ' year ' is not bissextile therefore February does not have 29 days'], 'Error!', opts);
error('Error occurred!');
end
if ((DD == 29) && (MM == 2) && (ycheck1 ~= Y/4))
errordlg(['Year ' year ' is not bissextile therefore February does not have 29 days'], 'Error!', opts);
error('Error occurred!');
else
RightAscensionDate; % this is a function I need to run.
run('ApogeePerigeeApp.mlapp');
end
end
Réponse acceptée
Rik
le 29 Nov 2018
The use of globals makes this an impossible task to debug. How are you making sure they are non-empty scalar values? If they aren't, the logical comparisons will yield either an empty logical array (not checked if that's true), or they will return a logical array, on which you can't use the short circuit operands.
The source of your problem is probably there.
4 commentaires
Rik
le 1 Déc 2018
You're very welcome, glad to be of help.
And yes, globals can be very tricky to use and almost always be avoided.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Develop Apps Using App Designer dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!