필터 지우기
필터 지우기

How do I have a loop for different data intervals.

조회 수: 4 (최근 30일)
Wan-Yi Chiu
Wan-Yi Chiu 2021년 7월 26일
답변: Chunru 2021년 7월 26일
I have a (m by n) matrix, for example:
A=rand(m,n)
First, I need the operations for the following submatrix (with different lengths).
A1=A(1:10,:)
T1=A1’*A1
A2=A(11:22,:)
T2=A2’*A2
A3=A(23:40,:)
T3=A3’*A3
and more ….
That is, I need different data interval for computations.
How can I do it by using a loop command?
Thank you very much.

채택된 답변

Chunru
Chunru 2021년 7월 26일
A=rand(50,10);
idx = [1 10; 11 22; 23 40];
for i=1:size(idx,1)
Anow = A(idx(i,1):idx(i,2), :);
T = Anow'*Anow;
end

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