필터 지우기
필터 지우기

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 (최근 30일)
(a1,N) = 1, if 2 does not divide N or 4 divides N

채택된 답변

Walter Roberson
Walter Roberson 2016년 3월 28일
hint: mod(N,2)
  댓글 수: 3
Walter Roberson
Walter Roberson 2016년 3월 28일
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.
Neha W
Neha W 2016년 3월 28일
Thank you Sir. Actually a1 and N are integers. N is an user input and a1 is fixed.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by