A very simple question about a column vector creation

1 次查看(过去 30 天)
I am an extra beginner MATLAB user. There is a 1:m command to create a 1 2 .... m row matrix. However, I couldn't find how to create a column vector as 12: 13-m. I mean (assume m=5):
12
11
10
9
8

采纳的回答

Star Strider
Star Strider 2016-7-9
If you want to decrement a vector, begin with the highest number and increment by a negative value to the desired end value. Here, the decrement value is -1:
m = 5;
v = [12: -1: m]'
v =
12
11
10
9
8
7
6
5
Is this what you want to do?
  2 个评论
Taner Cokyasar
Taner Cokyasar 2016-7-9
I got the logic. Thank you very much. This is what I was looking for.
m = 5;
v = [12: -1: 13-m]'
v =
12
11
10
9
8
Star Strider
Star Strider 2016-7-9
My pleasure.
My apologies for the inaccurate code. I misunderstood your Question.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by