필터 지우기
필터 지우기

Is there any other more efficient way of writing this code?

조회 수: 2 (최근 30일)
savvas
savvas 2015년 1월 18일
편집: per isakson 2015년 1월 18일
for tt=1:100
for t = 1:1000;
y = a*y0+e+w-a*w0;
y0 = y; w0 = w;
end
B(:,tt) = y(:,1);
end
  댓글 수: 1
Roger Stafford
Roger Stafford 2015년 1월 18일
편집: Roger Stafford 2015년 1월 18일
Savvas, I suspect you have left out some of the code for these for-loops. As it stands, the code makes no sense (or at least it is extremely inefficient.) After the first inner-loop iteration the values of w and w0 are equal and unchanging and any further computation of the step "w0 = w" is a total waste of time. Also you do not reset y and w for each outer-loop (tt) iteration, which has a very suspicious look. Please give us a realistic piece of code or else give a clear verbal description of your problem.
{Note: Unless the value of 'a' is extremely close to 1, your sequence of y values will converge to an essentially constant value or else to infinity long before you reach t = 1000.)

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by