Expanation for function length (x)-1

조회 수: 8 (최근 30일)
Engg.
Engg. 2022년 12월 30일
편집: DGM 2022년 12월 30일
what is the basic purpose of the function t=0:1/fs [length (x)-1]

답변 (1개)

DGM
DGM 2022년 12월 30일
편집: DGM 2022년 12월 30일
That's not a function, and it's not valid MATLAB syntax either. It's hard to say what it means, because I have to assume that it's assembled from unrelated pieces.
This
t=0:1/fs
creates a simple vector from 0 to 1/fs with a step size of 1. See colon, :
This
length(x)-1
returns the scalar length of the array x, minus 1. The "length" of an array is not dependent on its orientation; rather, it's the size of the longest dimension.
This
t=0:1/fs [length (x)-1]
will simply return an error. Implicit multiplication isn't allowed in MATLAB, so the juxtaposed expressions will result in an error. While not an error, wrapping the second expression in square brackets accomplishes nothing. Square brackets are used for concatenation, so you're trying to concatenate a scalar.

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by