how to divide the range of given integer number
8 views (last 30 days)
Show older comments
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 Comments
Answers (1)
Walter Roberson
on 21 Dec 2020
for GivenNumber = [20 10 30 3 25]
Walters_Half = GivenNumber/2;
ceil(-Walters_Half) : ceil(Walters_Half)-1
end
2 Comments
Image Analyst
on 21 Dec 2020
Jimmy, you can thank answerers by clicking the "Accept this answer" link to give them reputation points. Thanks in advance.
See Also
Categories
Find more on Data Types in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!