|
"Jimmy " <matias@chalmers.se> wrote in message <hcrnv6$iik$1@fred.mathworks.com>...
> I have a problem with discrete functions and labeling
>
> In my program I collect a vector of different lengths say, x=[1 1 2 3 1.4142 2.2361 2.2361 8]
>
> Length 1 and 2.2361 occurs 2 times and I would like to use this in the following manner...
>
> I have a associated vector v, which stores all possible lengths (in 3D)
> v=[1.0000 1.4142 1.7321 2.0000 2.2361 2.4495 2.8284...]
>
> and I write the occurences of X as
> X=[2 1 0 1 2 0...] which has the same length as v.
> I read out X as (together with v) 1.0000 occurs 2 times, 1.4142 occurs 1 time, 1.7321 occurs 0 times and so forth...
>
> But the problem is that to be able to create X I must loop over all possible lengths in v and check how many times they occur in x. This just does not seem right as it will be a very slow process. This seem to be a standard question, and I wonder if there there are functions to handle these types of questions/labeling issues? Any ideas would be highly appreciable.
>
> Best regards!
> Jimmy
I posted a function howmany to FEX today. It counts the occurrences of values in an array. It doesn't count the ones not included (zero counts), you'll have to add those, intersect for example might help there.
|