What is the best way to execute 2 if conditions in MATLAB

 Risposta accettata

José-Luis
José-Luis il 30 Apr 2014
Modificato: José-Luis il 30 Apr 2014
for ii = 1:numel(w)
if (w(ii) == 1)
%stuff
else if (q(ii) == 1)
%stuff
else
%stuff
end
end
Please accept an answer if it helps you.

Più risposte (1)

if w(i) == 1
do somehing
elseif q(i) == 1
do some thing
else
do somthing
end

2 Commenti

Thanks for your answer.I just want to know about the third statement,will the program check w or q .I guess w? Thanks
It will check nothing. It will run that bit only if any of the first two conditions are not satisfied.

Accedi per commentare.

Categorie

Scopri di più su Programming in Centro assistenza e File Exchange

Prodotti

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by