cycle for integrating vector sections

조회 수: 1 (최근 30일)
Lev Mihailov
Lev Mihailov 2020년 7월 21일
댓글: Alan Stevens 2020년 7월 21일
Hello! I have a vector that I need to integrate over the sections, the length of the section is 3
% now I use such a loop, but it gives me 900 answers, but should 300
for i=1:length(Fi)
x=Fi(i:i+2); % +2 I need to integrate sections (3 values ​​per section)
LayerDepstep(i)=trapz(x);
end
% x=900 % 300
% Fi vector 1:900 %

답변 (1개)

Alan Stevens
Alan Stevens 2020년 7월 21일
Perhaps you should have something like:
for i=1:4:length(Fi)-2
x=Fi(i:i+2); % +2 I need to integrate sections (3 values ​​per section)
LayerDepstep(floor(i/4)+1)=trapz(x);
end
  댓글 수: 2
Lev Mihailov
Lev Mihailov 2020년 7월 21일
i tested this method but it didn't help me
Alan Stevens
Alan Stevens 2020년 7월 21일
It does what you appeared to be asking for, i.e. reduces the number of sections by a factor of 3. What problem remains?

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

카테고리

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