Expanation for function length (x)-1
8 views (last 30 days)
Show older comments
what is the basic purpose of the function t=0:1/fs [length (x)-1]
0 Comments
Answers (1)
DGM
on 30 Dec 2022
Edited: DGM
on 30 Dec 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.
0 Comments
See Also
Categories
Find more on Logical in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!