필터 지우기
필터 지우기

Substitution

조회 수: 2 (최근 30일)
Ferd
Ferd 2012년 3월 28일
Hey
I need to substitute the last element of the Steps array with the LastStep value. This is my code for the section;
CycleStep = 0;
for k = 1:7
Steps(k) = 1;
CycleStep = CycleStep + 1;
if CycleStep == 7
LastStep = 10 - Steps(k)*(7 - 1);
end
end
Steps(Steps(7))=LastStep;
but somehow it is substituting the first value of the Steps array. How do I replace the last value of the Steps with the LastStep value?

채택된 답변

Wayne King
Wayne King 2012년 3월 28일
Just
Steps(end) = LastStep;
You are doing:
Steps(Steps(7))
but Steps(7) is 1, so your code is saying "Assign Steps(1) the value LastStep.
  댓글 수: 1
Ferd
Ferd 2012년 3월 28일
Oh yea... Thanks Wayne!!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by