필터 지우기
필터 지우기

creating a loop of a 158 component vector

조회 수: 2 (최근 30일)
scientist121
scientist121 2021년 11월 30일
편집: scientist121 2021년 12월 1일
Hi,
How would i set up a for loop in which the loop variable runs from 0 to 100 in steps of 0.1?

답변 (1개)

Steven Lord
Steven Lord 2021년 11월 30일
As shown in the "Decrement Values" example on the documentation page for the for keyword, you can specify a vector with start, increment, and ending values as the values over which for iterates. Replace the 1.0, -0.2, and 0.0 values with the appropriate values for your problem (left as an exercise for the reader.)
  댓글 수: 2
scientist121
scientist121 2021년 11월 30일
Hi, i am still unsure of what i need to do. Can you explain what code is needed for the loop?
Steven Lord
Steven Lord 2021년 11월 30일
Can you create that vector as a separate variable, not worrying about using it in a for loop? If you can then you can use that vector in your for loop.
If you're not sure how to create that vector, look at the examples in the documentation for the colon operator.
doc colon
I'm hesitant to simply give you the code as this sounds like a homework assignment.

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

카테고리

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

태그

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by