length(fin​d((XM(2:en​d)>126.5 & XM(1:end-1)<126.5)| (XM(2:end)<126.5 & XM(1:end-1)>126.5)));

1 回表示 (過去 30 日間)
Mattia Bussotti
Mattia Bussotti 2022 年 2 月 23 日
編集済み: KALYAN ACHARJYA 2022 年 2 月 23 日
Can anyone tell me if in this function the terms XM (2: end) and XM (1: end-1) indicate two successive elements of the vector ?. If so, why? thank you in advance

回答 (2 件)

KALYAN ACHARJYA
KALYAN ACHARJYA 2022 年 2 月 23 日
編集済み: KALYAN ACHARJYA 2022 年 2 月 23 日
It represent the total elements in the vector (Except First One)
XM(2:end)
It represent the total elements in the vector (Except last one)
XM(1:end-1)
Indicate two successive elements of the vector (Multiple ways)
XM(1:2)
XM(i:i+1)
XM(end-1:end)
.....

KSSV
KSSV 2022 年 2 月 23 日
編集済み: KSSV 2022 年 2 月 23 日
They represent second to last and first to last but one elements respectively.
% Example
a = rand(5,1) ;
a
a = 5×1
0.9264 0.3197 0.4573 0.7790 0.4464
[a(2:end) a(1:end-1)]
ans = 4×2
0.3197 0.9264 0.4573 0.3197 0.7790 0.4573 0.4464 0.7790
If you want sucessive elements, it should be
[a(1) a(2)]
[a(4) a(5)]
i,e, a(i) and a(i+1)

カテゴリ

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

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by