how to divide the range of given integer number
조회 수: 3 (최근 30일)
이전 댓글 표시
Hi guys,
Might the deadline of my problem isn't understandable, so here Im explaining my problem.
Im trying to do a range of given integer number between negative and positive (including zero and assume zero is positive ..this just assumption in my case) equally -meaning by equally that the negative number and positive numbers are equally in the two sides, this means :
GivenNumber is an integer parameter (assume it's bigger than 0 )
lets assume I have number 20, GivenNumber=20 so the output is the range : [-10:9] , implicitly the number of numbers/samples in the range [-10:9] are 20 which it's the Givennumber - you can easily see the negative numbers are equally to the positive numbers (including zero as my assumption as positive).
lets assume I have number 10, GivenNumber=10 so output is the range : [-5:4] , implicitly the number of numbers/samples in the range [-5:4] are 10 which it's the Givennumber - you can easily see the negative numbers are equally to the positive numbers (including zero as my assumption as positive).
lets assume I have number 30, GivenNumber=30 so output is the range : [-15:14] , implicitly the number of numbers/samples in the range [-15:14] are 30 which it's the Givennumber - you can easily see the negative numbers are equally to the positive numbers (including zero as my assumption as positive).
So how can I do a function in matlab to get as parameter : GivenNumber , the output is the range as explained above?
Appreciated !
댓글 수: 0
답변 (1개)
Walter Roberson
2020년 12월 21일
for GivenNumber = [20 10 30 3 25]
Walters_Half = GivenNumber/2;
ceil(-Walters_Half) : ceil(Walters_Half)-1
end
댓글 수: 2
Image Analyst
2020년 12월 21일
Jimmy, you can thank answerers by clicking the "Accept this answer" link to give them reputation points. Thanks in advance.
참고 항목
카테고리
Help Center 및 File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!