- to avoid bugs by ensuring that a variable has the correct data type (often overlooked in answers).
- to improve efficiency by preallocating an array to the required size:
Why should I use the zeros function?
21 ビュー (過去 30 日間)
古いコメントを表示
Hello, I don't understand. Why should I use the zeros function?
Eb=zeros(1,8640);
time1=zeros(1,8640);
diesel=zeros(1,8640);
Edump=zeros(1,8640);
Edch=zeros(1,8640);
Ech=zeros(1,8640);
In this case, I don't understand zeros(1,8640). please explain to me
2 件のコメント
回答 (2 件)
Durganshu
2020 年 10 月 22 日
Zeros(m,n) will create a matrix of dimensions m x n with all the elements as 0. This matrix along with the ones(m,n) is often used to pre-allocate a matrix so as to save memory and time of processing.
Read the full documentation here:
Hope that helps!
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!