How do i step from a bigger number to a smaller number ?
8 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Nuri Efe Tatli
am 30 Jun. 2021
Kommentiert: Nuri Efe Tatli
am 2 Jul. 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 ?
0 Kommentare
Akzeptierte Antwort
Image Analyst
am 30 Jun. 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)
Weitere Antworten (2)
Akshit Bagde
am 30 Jun. 2021
If you want to create a decrement array, you should use
Xprime = x1:-0.01:x2;
0 Kommentare
Siehe auch
Kategorien
Mehr zu Stability Analysis finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!