From: John Gar on 6 Jun 2010 14:38 Walter Roberson <roberson(a)hushmail.com> wrote in message <OLGEn.11$0M5.3(a)newsfe07.iad>... > John Gar wrote: > > > I want to perform a vector operation. > > I have a vector with a number X of elements and I want to divide this > > vector to sub-groups. For example, i have a table with groups: > > > > 0 -100, 100 - 200, 200-300, 300-400, 400-510, 510 - 630, 630-770, > > 770-920,... > > > > and I want to make some operation in my vector according to each group > > separately (the groups are the index of the vector). > > > > How can I made such division? I can made it using "if", but it not seems > > to be a good and proper solution. > > Store the breakpoints in a vector, e.g., > > BP = [0 100 200 300 400 510 630 770 920 X]; > > for K = 2:length(BP) > Subvector = Vector(BP(K-1)+1:BP(K)); > operate on Subvector... > end > Thanks to Walter I have the code that perform the operation in a Subvector and also in each group. Continuing this post - I have another question. In each Sub vector I need to find the maximum amplitude of my vector and change the values near to the max amplitude. But, it's a continues change, i.e, in the first Subvector I change the nearest amplitudes of the maximum to zero (both sides of the max). The second Subvector change both sides of max to 1, the third change one side to 1 and the other to 0, the fourth one to 0 and the other side to 1, and it cames back to both sides to zero. (It's like a bit sequence). I think to made this operation bu using of 'case' procedure, but maybe someone can help me with a simple and better solution. Thank you.
From: Walter Roberson on 6 Jun 2010 18:33 John Gar wrote: > In each Sub vector I need to find the maximum amplitude of my vector and > change the values near to the max amplitude. > But, it's a continues change, i.e, in the first Subvector I change the > nearest amplitudes of the maximum to zero (both sides of the max). The > second Subvector change both sides of max to 1, the third change one > side to 1 and the other to 0, the fourth one to 0 and the other side to > 1, and it cames back to both sides to zero. (It's like a bit sequence). > I think to made this operation bu using of 'case' procedure, but maybe > someone can help me with a simple and better solution. switch/case would work fine. You could switch on mod(LoopIndex,4)
|
Pages: 1 Prev: HMM - speech recognition Next: [GUI] Standard Figure Window |