List all 6 whole number between -3.5 and 5.5

6 ビュー (過去 30 日間)
Kathy Andrews
Kathy Andrews 2022 年 11 月 29 日
コメント済み: Vilém Frynta 2022 年 11 月 30 日
この 質問 は Star Strider さんによってフラグが設定されました
List all 6 whole number between -3.5 and 5.5
  1 件のコメント
Image Analyst
Image Analyst 2022 年 11 月 29 日
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
Vilém Frynta 2022 年 11 月 29 日
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().
  4 件のコメント
David Goodmanson
David Goodmanson 2022 年 11 月 29 日
編集済み: David Goodmanson 2022 年 11 月 29 日
Hi Vilem,
Helping with homework is unpopular here when people make no attempt at a problem and appear to be looking for someone to just supply them with an answer. On the other hand If someone has made a real effort, for example by posting some code that is a good approach but doesn't quite work, or something similar, then giving that person some assistance can be an appropriate thing to do.
Vilém Frynta
Vilém Frynta 2022 年 11 月 30 日
Understood, thanks.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeProgramming についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by