Indexing multiple values over large array?

2 ビュー (過去 30 日間)
MohammedLee Lee
MohammedLee Lee 2013 年 12 月 17 日
コメント済み: MohammedLee Lee 2013 年 12 月 18 日
It seems like there would be a function for this but no idea what it would be. Basically,I have an vector generated by histc, e.g.:
1
3
1
0
1
and what it's referring to;
150018
150470
150899
151353
151770
152753
153242
i.e. the first value (150018) is the first bin, the next three values the second bin etc., but I now need to subtract each value in each bin from varying values in another vector - values in bin1-value1, values in bin3(three of them)-value2 and so on.....
I don't see how to do this quickly, but I hope someone know how to use a built-in function and could help?
  3 件のコメント
Sean de Wolski
Sean de Wolski 2013 年 12 月 17 日
There are seven values but only six in bins...
MohammedLee Lee
MohammedLee Lee 2013 年 12 月 18 日
bin corresponding to 0 means there are none of the 6 figure values from that vector between binrange values (another vector not shown)
Also the values don't match in size just cause I used them as examples, sorry for the confusion

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

回答 (1 件)

Oliver Woodford
Oliver Woodford 2013 年 12 月 17 日
histc outputs the bin index of each input value in the second output argument. So you can do:
[~, ind] = histc(vals);
vals = vals - off(ind);

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by