Find all values between 2 index columns

1 vue (au cours des 30 derniers jours)
Jonathan Cheong
Jonathan Cheong le 2 Mar 2021
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.

Réponse acceptée

KSSV
KSSV le 2 Mar 2021
Modifié(e) : KSSV le 2 Mar 2021
for i = 1:size(c,1)
value = dataset(C(i,1):C(i,2));
end
  5 commentaires
KSSV
KSSV le 2 Mar 2021
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 le 2 Mar 2021
Nice, thanks a bunch.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Matrix Indexing dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by