How do I initialize a complex array to zeros in MATLAB?
이전 댓글 표시
MATLAB documentation recommends that pre-allocation of variables speeds up performance. I would like to pre-allocate a complex array in my code to zeros. However, when I type the following commands:
x = zeros(100,1) + j*zeros(100,1);
MATLAB creates a 100-by-1 real double array. I would like to create a complex array and initialize both the real and imaginary parts to zeros.
채택된 답변
추가 답변 (1개)
Royi Avital
2020년 12월 29일
편집: Royi Avital
2020년 12월 29일
3 개 추천
In later versions one could do something like vB = zeros(3, 1, 'like', 1j);.
카테고리
도움말 센터 및 File Exchange에서 Logical에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!