Expanation for function length (x)-1

9 vues (au cours des 30 derniers jours)
Engg.
Engg. le 30 Déc 2022
Modifié(e) : DGM le 30 Déc 2022
what is the basic purpose of the function t=0:1/fs [length (x)-1]

Réponses (1)

DGM
DGM le 30 Déc 2022
Modifié(e) : DGM le 30 Déc 2022
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.

Catégories

En savoir plus sur Matrix Indexing dans Help Center et File Exchange

Tags

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by