필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Brief question: faster to zero before direct computation?

조회 수: 2 (최근 30일)
Miguel
Miguel 2014년 12월 18일
마감: Miguel 2014년 12월 18일
Hello all, quick question,
in the simplest of examples,
x1a = linspace(-1,1,100);
y1a = zeros(1,100);
y1a = x1a.^3;
Is it a clear computational speed and economy advantage to declare y1a first with zeros, or not, in this simple case?
Is the cube operation one that does not require nor benefit from variable declaration?
Cheers
  댓글 수: 4
per isakson
per isakson 2014년 12월 18일
편집: per isakson 2014년 12월 18일
Not just confusing. It was wrong; a "no" was missing. I've edited the comment.
Miguel
Miguel 2014년 12월 18일
Ok then, I reckon this answers it, I would like to know, however, if the statement y1a = x1a.^3 is something that builds the y1a variable one by one increasing its size after each value is computed, or, what I am suspecting is the case, applies the operation first to the x1a matrix, and then assigns this to variable y1a?

답변 (0개)

이 질문은 마감되었습니다.

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by