5

I have a matlab vector like s=[1 2 3 4]' and iterate over every element:

for i=1:length(s)
  cal_function(s(i));
end

what is the correct mathematic notation of the length-Function? I found some papers which write the length as $|s|$ but I don't know if this is correct as I have never seen this before.

jrast
  • 153
  • 1
    $|s|$ usually refers to the Euclidean length of the vector, i.e., $\sqrt{s_1+s_2+\dots+s_d}$, where $d$ is the dimensionality of the vector (4 in your case). So I don't think $|s|$ or $||s||$ is the notation you want to use, since you seem to be referring to the number of elements in $s$. – HelloGoodbye Sep 25 '20 at 00:26

1 Answers1

3

That depends on the context. When thinking of vectors, especially in finite-dimensional normed spaces, $\lvert \cdot\rvert$ sometimes is used to denote the norm (though most of the time, $\lVert\cdot\rVert$ is used for that). At those times, the length is usually clear from the context or entirely immaterial.

When talking about abstract tuples, it's almost always the length (number of entries) of the tuple, and I'm not aware of any other common notation.

tomasz
  • 35,474