How can I map consecutive elements to a vector value?

3 ビュー (過去 30 日間)
James
James 2014 年 12 月 5 日
コメント済み: Mohammad Abouali 2014 年 12 月 5 日
Hello -
I'm a bit of a novice, and could use a hand. I have a data set, which I have manipulated to output row and column indices in two variables (I used [r,c,v]=find(1 < X & X < 5), to generate the row and column indices). I also have two vectors, a 1 x 41 that corresponds to the number of total columns (t), and another 22198 x 1 that corresponds to the total number of rows (m). What I would like is for the final product to be a two column list with 'm' as column 1 and 't' as column 2. Is there a way to relate the values in 'r' to the values in 'm' (the same for 'c' and 't')? For instance, any time a '1' is observed in 'r', the value of the first element in 'm' is returned, thus generating a peak list of sorts.
Thank you all in advance.

採用された回答

Mohammad Abouali
Mohammad Abouali 2014 年 12 月 5 日
That is easy,
r and c are the row and column index of X. I am assuming X is of size 22198x41, (since your m is 22198 and your t is 41); So if you want to get the corresponding numbers out just do this
m(r)
t(c)
so if r=1 then first element of M is returned. if r=10 then 10th element of M is returned. The same goes for t.
  2 件のコメント
James
James 2014 年 12 月 5 日
Thank you very much for your help!! Still have a lot of learning to do. . .
Mohammad Abouali
Mohammad Abouali 2014 年 12 月 5 日
You are welcome.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCell Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by