开发者

summing vector having cells=inf values

I need to find out the average of the values

Columns 1 through 17

    0.3108    开发者_运维百科0.7273       Inf    0.2878   -0.0947    0.1286   -0.3108    0.5634    0.2822    0.2362   -0.2628    0.0960   -0.1675   -0.0934   -0.1710   -0.3077   -0.2726

Columns 18 through 20

   -0.0630   -0.5097    0.1823

How do I exclude the inf?


>> a=[0.3108    0.7273       Inf    0.2878   -0.0947    0.1286   -0.3108    0.5634    0.2822    0.2362   -0.2628    0.0960   -0.1675   -0.0934   -0.1710   -0.3077   -0.2726 -0.0630 -0.5097 0.1823];
>> mean(a(~isinf(a)))

ans =

    0.0295

or mean(a(a<inf)).


To find how many are Inf:

1) find the infs

Allvalues{1}<inf                    
ans =
     1     1     0     1     1     1     1     1     1     1     1     1     1     1     1     1     1     1     1     1

2) Find the number of 0s == Inf

sum(~(Allvalues{1}<inf))
ans =
     1

Is there another way?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜