필터 지우기
필터 지우기

Question about column operator vectors

조회 수: 2 (최근 30일)
Anne Nguyen
Anne Nguyen 2019년 10월 14일
편집: per isakson 2019년 10월 14일
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!

채택된 답변

per isakson
per isakson 2019년 10월 14일
편집: per isakson 2019년 10월 14일
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

추가 답변 (1개)

Andrei Bobrov
Andrei Bobrov 2019년 10월 14일
Use
vec = -1:-1:-5
or
vec = -(1:5)

카테고리

Help CenterFile Exchange에서 Environment and Settings에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by