フィルターのクリア

Taking values out of a vector

7 ビュー (過去 30 日間)
Rohan Savakar
Rohan Savakar 2020 年 4 月 16 日
編集済み: Stephen23 2020 年 4 月 16 日
What is the meaning of the following statement?
Where column is a variable with a size of N
column = % some set of values
N = size(column)
column([1 N(1):-1:2])
In general when we use a paranthese infront of the variable name, we are taking the values of the positions in the vector
Using the syntax of
:
we get all the values corresponding to the appropriate row/column,
But what happens when you input an array as shown above in the same parentheses.

採用された回答

Stephen23
Stephen23 2020 年 4 月 16 日
編集済み: Stephen23 2020 年 4 月 16 日
"What is the meaning of the following statement?"
It really is just basic MATLAB operations.
1- The square brackets and the colon operator simply define a vector of these values:
[1,N(1),N(1)-1,N(1)-2,...,4,3,2]
2- that vector of values is used as a index into column.
Assuming that column is a vector, the effect is to access the elements (2:end) of column in reverse order, with the first element still in the first position. It would probably be simpler to use end:
column([1,end:-1:2])

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSolver Outputs and Iterative Display についてさらに検索

タグ

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by