/ tutorials / wave-acoustics
Sign in
tutorials / wave-acoustics
wave-acoustics / src / matlab / wv_vec.m
8 lines · 344 BBlameHistoryRaw
1function c = wv_vec(v)
2% WV_VEC Wrap a vector so that jsonencode always produces an array.
3%
4% jsonencode(5) is 5 and jsonencode([5]) is also 5, so a per-method quantity
5% arrives on the JavaScript side as a bare number whenever a lab happens to
6% show one method. A cell array of scalars always encodes as an array.
7c = num2cell(v(:)');
8end
↑↓ move↵openescclose