# List all 6 whole number between -3.5 and 5.5

7 views (last 30 days)
Kathy Andrews on 29 Nov 2022
Commented: Vilém Frynta on 30 Nov 2022
This question was flagged by Star Strider
List all 6 whole number between -3.5 and 5.5
##### 1 CommentShow NoneHide None
Image Analyst on 29 Nov 2022
Since that would be -3 -2 -1 0 1 2 3 4 5, which is 9 numbers, which subset of 6 do you want? The non-negative ones like 0 through 5?
This looks like a homework problem. If you have any questions ask your instructor or read the link below to get started:
Obviously we can't give you the full solution because you're not allowed to turn in our code as your own.

Vilém Frynta on 29 Nov 2022
If I understand correctly, you can do it like this:
a = -3.5;
z = 5.5;
aWhole = ceil(a)
aWhole = -3
zWhole = floor(z)
zWhole = 5
list = aWhole:1:zWhole
list = 1×9
-3 -2 -1 0 1 2 3 4 5
If you wish to automate this, you can add some if statements (if a < 0) --> use ceil() or (if a > 0) --> use floor().
Vilém Frynta on 30 Nov 2022
Understood, thanks.

### Categories

Find more on Logical 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!