length
result = numel(x)
Input: x · Output: result
What it is
Total element count of x: 1 for a scalar, its length for a Vec/CVec/Signal, rows*cols for a Mat, a Unicode-aware character count for a Str, and the element/node count for List/Record/Dict/fifo/linked_list/graph.
Overloads
One call shape — this function is not overloaded.
| Code | Input | Output | Description |
result = numel(x) | x scalar, Vec, CVec, Signal, Mat, Str, List, Record, or Dictnot documented yet | result scalar or Num | Returns a scalar Num. |
Examples
From the documentation, and run by the build -- the output and the figure below are what the engine actually produced. Simplest first.
body = http_get("https://example.com/")
print(length(body)) # e.g. 559 -- byte length of the fetched page
output
559
from concurrency
body = http_get("https://example.com/")
print("len = {length(body)}")
from tour
fs = 1000
lp = fir1(20, 100, kind="low", fs=fs)
bp = fir1(20, [80, 120], kind="band", fs=fs)
print("lowpass taps: {length(lp.b)}") # lowpass taps: 21
print("bandpass taps: {length(bp.b)}") # bandpass taps: 21
output
lowpass taps: 21 bandpass taps: 21
from signal-processing
x = [1, 2, 3, 4]
h = [1, 1, 1]
f = conv(x, h)
s = conv(x, h, mode="same")
v = conv(x, h, mode="valid")
print("full ({length(f)}): {f}") # full (6): [1, 3, 6, 9, 7, 4]
print("same ({length(s)}): {s}") # same (4): [3, 6, 9, 7]
print("valid ({length(v)}): {v}") # valid (2): [6, 9]
output
full (6): [1, 3, 6, 9, 7, 4] same (4): [3, 6, 9, 7] valid (2): [6, 9]
from signal-processing
See also
numel — documented in the same entry.