Try and Catch for multiple conditions
22 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello. If I have say 10 conditions and each one may fail, rather than have a try and catch round each condition, is there a better way where if condtion 1 isnt met, it ignores it and moves onto condition2?
0 commentaires
Réponse acceptée
Les Beckham
le 6 Avr 2022
Modifié(e) : Les Beckham
le 6 Avr 2022
Maybe something like this:
if isfield(src, 'DeviceName')
Name = src.DeviceName;
else
Name = 'unknown'; % or, just don't set the Name (leave off the else part)
end
if isfield(src, 'Model')
Model = src.Model;
else
Model = 'unknown';
end
% and so on...
0 commentaires
Plus de réponses (1)
David Hill
le 6 Avr 2022
if condition1
%do
elseif condition2
%do
elseif condition3
%do
elseif condition4
%do
elseif condition5
%do
elseif condition6
%do
end
1 commentaire
Voir également
Catégories
En savoir plus sur GigE Vision Hardware 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!