Does 'zeros' overwrite existing memory or alocate new memory and replace adress?

조회 수: 2 (최근 30일)
I have a matrix inside a handle class, that needs to be reset to zero from time to time. Does
A=zeros(size(A))
replace the matrix adress with a new adress? If so, is alocating new memory faster than reseting existing memeory?
Thank you.

채택된 답변

Jos (10584)
Jos (10584) 2014년 1월 7일
To set all elements of an existing array A to zero, A(:)= 0 is recommended (and faster).

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by