If N is given and I need to make a choice for a1, then using if else statements how should I apply the following condition:
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Neha W
am 28 Mär. 2016
Kommentiert: Neha W
am 28 Mär. 2016
(a1,N) = 1, if 2 does not divide N or 4 divides N
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 28 Mär. 2016
hint: mod(N,2)
3 Kommentare
Walter Roberson
am 28 Mär. 2016
That looks like it would work, if you are looping over a1 and N.
That code will not work if a1 or N are vectors.
Note that the definition you gave would also be satisfied by setting all locations to 1, since the definition does not say what should happen at any location where N has any other value.
By the way: how is that definition "making a decision about a1" ? The definition ignores a1.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!