question about x(1:n) vs x(n:1)

10 ビュー (過去 30 日間)
cgo
cgo 2015 年 10 月 29 日
回答済み: Ingrid 2015 年 10 月 29 日
If we want to create a row vector with elements '20' then we can say: x(1:n) = 20. (n is a number you can specify). Why is it not possible to create x(n:1) = 20 (A column vector full of 20's). Of course, we can just say x(1:n)'.

回答 (1 件)

Ingrid
Ingrid 2015 年 10 月 29 日
you can use this to create a column vector since you just need to define that there is only one column
x(1:n,1) = 20;
but another, more elegant way is
x = ones(n,1) * 20;

カテゴリ

Help Center および File ExchangeWhos についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by