Pre allocation in matlab
1 回表示 (過去 30 日間)
古いコメントを表示
v = [0 8 1 2 6 4 8]
How do I determine length of the vector?
Also, how do I pre-allocate the descending vector with all zeros?
Thank you!
0 件のコメント
採用された回答
Walter Roberson
2020 年 2 月 10 日
length(v)
zeros(size(v))
3 件のコメント
Walter Roberson
2020 年 2 月 10 日
zeros(size(v)) works no matter whether you are planning to put ascending or descending variables; it also works even if you are planning to put complex numbers in (I mention those because complex numbers cannot generally be ordered into ascending or descending.)
その他の回答 (1 件)
fred ssemwogerere
2020 年 2 月 10 日
leng=length(v); % length of a vector
pA=zeros(1,leng); % pre-allocation with zeros
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!