0
votes

I need to store some values of certain size (nsents) into a variable like scount below. This array stores numbers (scores) and later the values in the variable scount will be divided with those of a similar array in order to get total scores. Some of these values (scores) are zero. During scoring, not all of the indexes in the array are considered. The positions with 0 score are taken as 'empty' whereas actually the index was considered. I could change the size of the array but that won't work for the rest of my code.

scount = zeros(1,nsents);

If I ignore the zeros with something like

totalscores(totalscores==0) = []; 

then along with the indexes that were not used I ignore those that were used but had zero score. Do you have any idea how I could solve this problem ? I am very new to Matlab so I apologize if my question is not very clear. Thanks

1

1 Answers

0
votes

It is easy to solve.First,find the position where scount is not zero,the code is:

LL=find(scount~=0);

then,scoring the non-zeros elements only.For example,the scoring function is score=1./scount,the code is:

score=zeros(1,nsents);
score(LL)=1./scount(LL);

so,with the help of position variable LL,the scoring process has nothing to do with the scounts that are zero. Hope it's helpful.Thanks.