フィルターのクリア

How do i step from a bigger number to a smaller number ?

8 ビュー (過去 30 日間)
Nuri Efe Tatli
Nuri Efe Tatli 2021 年 6 月 30 日
コメント済み: Nuri Efe Tatli 2021 年 7 月 2 日
I want to create an array with two numbers like this;
Xprime = x1 : 0.01 : x2
but when i make x1 > x2 i get an empty array.
Is there a solution to this ?

採用された回答

Image Analyst
Image Analyst 2021 年 6 月 30 日
In general, if you don't know what x1 and x2 are, and which one will be bigger, you can do
x1 = 3
x2 = 2
inc = 0.01;
xPrime = x1 : sign(x2-x1) * inc : x2
If you know how many steps you want between the two, you can use the linspace() function instead:
numSteps = 10;
xPrime = linspace(x1, x2, numSteps)

その他の回答 (2 件)

Akshit Bagde
Akshit Bagde 2021 年 6 月 30 日
If you want to create a decrement array, you should use
Xprime = x1:-0.01:x2;

KSSV
KSSV 2021 年 6 月 30 日
x = 2:-0.01:1
x = 1×101
2.0000 1.9900 1.9800 1.9700 1.9600 1.9500 1.9400 1.9300 1.9200 1.9100 1.9000 1.8900 1.8800 1.8700 1.8600 1.8500 1.8400 1.8300 1.8200 1.8100 1.8000 1.7900 1.7800 1.7700 1.7600 1.7500 1.7400 1.7300 1.7200 1.7100

カテゴリ

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

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by