Effacer les filtres
Effacer les filtres

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

8 vues (au cours des 30 derniers jours)
Nuri Efe Tatli
Nuri Efe Tatli le 30 Juin 2021
Commenté : Nuri Efe Tatli le 2 Juil 2021
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 ?

Réponse acceptée

Image Analyst
Image Analyst le 30 Juin 2021
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)

Plus de réponses (2)

Akshit Bagde
Akshit Bagde le 30 Juin 2021
If you want to create a decrement array, you should use
Xprime = x1:-0.01:x2;

KSSV
KSSV le 30 Juin 2021
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

Catégories

En savoir plus sur Stability Analysis dans Help Center et File Exchange

Produits


Version

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by