how can i solve this error?

조회 수: 3 (최근 30일)
zahra zamani
zahra zamani 2020년 5월 18일
댓글: zahra zamani 2020년 5월 18일
Hi . i wanna write h(x) at a for loop. but i have error .
error is : '' Index in position 1 exceeds array bounds (must not exceed 1). "
x=1:0.1:6;
for i=1:0.1:6
h(i,:)=z2+(x(i,:)-ls)*z4;
end

채택된 답변

Stijn Haenen
Stijn Haenen 2020년 5월 18일
편집: Stijn Haenen 2020년 5월 18일
You should use this:
x=1:0.1:6;
for i=1:numel(x)
h(i,:)=z2+(x(i)-ls)*z4;
end
or even without ':'
x=1:0.1:6;
for i=1:numel(x)
h(i)=z2+(x(i)-ls)*z4;
end
  댓글 수: 1
zahra zamani
zahra zamani 2020년 5월 18일
thank you so much
error been solve.

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

추가 답변 (1개)

KSSV
KSSV 2020년 5월 18일
편집: KSSV 2020년 5월 18일
x=1:0.1:6;
for i=1:length(x)
h(i)=z2+(x(i)-ls)*z4;
end

카테고리

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