필터 지우기
필터 지우기

Find all values between 2 index columns

조회 수: 5 (최근 30일)
Jonathan Cheong
Jonathan Cheong 2021년 3월 2일
댓글: Jonathan Cheong 2021년 3월 2일
Say two columns (C) be this:
1 5
7 13
20 32
These are index values. The 1st column is the starting index, the 2nd column the ending index.
I want to find all values from (dataset) between these 2 index columns.
If i use this code, it only gives me values for the 1st row.
value = dataset(C(:,1):C(:,2));
How do I code this, so that it gives me all the values for every index row?
Many thanks.

채택된 답변

KSSV
KSSV 2021년 3월 2일
편집: KSSV 2021년 3월 2일
for i = 1:size(c,1)
value = dataset(C(i,1):C(i,2));
end
  댓글 수: 5
KSSV
KSSV 2021년 3월 2일
load index.mat ;
load Rain.mat ;
N = size(ddindex,1) ;
ddvalue = cell(N,1) ;
for ai = 1:size(ddindex,1)
ddvalue{ai} = rain(ddindex(ai,1):ddindex(ai,2));
end
Jonathan Cheong
Jonathan Cheong 2021년 3월 2일
Nice, thanks a bunch.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by