필터 지우기
필터 지우기

SAVING DATA FROM A LOOP THAT DOES NOT START FROM ONE OR NOT POSITIVE INTEGERS OR LOGICALS

조회 수: 1 (최근 30일)
hello for exmplae i want to start a loop from zero like this :
{
for i=0:0.1:10
y(i)=i*10
end
}
but since i am not starting from one and the numbers are not positive integers i cant run the loop , what to do ?

채택된 답변

Star Strider
Star Strider 2017년 11월 26일
If you want to use a for loop, you need to make a few changes:
v = 0:0.1:10; % Create Values As A Separate Vector
for i = 1:length(v) % Index Through The Length Of The Vector
y(i)= v(i)*10; % Reference The Elements Of The Vector In The Calculation
end
  댓글 수: 4
tomer polsky
tomer polsky 2017년 11월 27일
편집: tomer polsky 2017년 11월 27일
ok i have onther question maeyby you could help me ;lets say now insted of 10 i have this vector A=[2 3;4 5] and for each loop i want to multupley the vector by the elemnt of i ,for exmpale :
first loop :0.1*A
second loop :0.2*A
third loop :0.3 * A
and keep doing it , how do i do it ? and of course keeping all the data
never mind I did it thank you anyway
Star Strider
Star Strider 2017년 11월 27일
‘never mind I did it thank you anyway’
My pleasure!

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

추가 답변 (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