How do I initialize a complex array to zeros in MATLAB?
Mostrar comentarios más antiguos
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.
Respuesta aceptada
Más respuestas (1)
Royi Avital
el 29 de Dic. de 2020
Editada: Royi Avital
el 29 de Dic. de 2020
3 votos
In later versions one could do something like vB = zeros(3, 1, 'like', 1j);.
Categorías
Más información sobre Logical en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!