Question about column operator vectors

1 Ansicht (letzte 30 Tage)
Anne Nguyen
Anne Nguyen am 14 Okt. 2019
Bearbeitet: per isakson am 14 Okt. 2019
Why does vec = -1:-5 not output -1 -2 -3 -4 -5? Why does it say 1x0 empty double row vector? An explanation of this would be great. Thank you!

Akzeptierte Antwort

per isakson
per isakson am 14 Okt. 2019
Bearbeitet: per isakson am 14 Okt. 2019
x = j:k creates a unit-spaced vector x with elements [j,j+1,j+2,...,j+m] ...
x = j:i:k creates a regularly-spaced vector x using i as the increment ...
Thus the default value of the step, i, is +1 (one).
>> vec = -1:+1:-5
vec =
1×0 empty double row vector
and
>> vec = -1:+5
vec =
-1 0 1 2 3 4 5

Weitere Antworten (1)

Andrei Bobrov
Andrei Bobrov am 14 Okt. 2019
Use
vec = -1:-1:-5
or
vec = -(1:5)

Kategorien

Mehr zu Environment and Settings finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by