[Scilab-users] Count specific values in text file

arctica1963 arctica1963 at gmail.com
Tue Feb 11 13:10:56 CET 2020


Hello all,

Basic query. I have text files of Pi and e to a million places and I want to
scan the number for the occurrences of particular values and the separation
of those values in the number.

This code snippet works on a vector:

// create vector of elements

A=[1 2 3 4 5 6 7 8 9 1 1 1 1 1 1 4 4 5 5 5 5 8 8];

// Count number of values, e.g. 1

Val_count1= sum(A==1)

disp(Val_count1) // answer 7

I can open the text file with pinum=mopen('pi-million.txt','rt') - but does
it need to be changed to a vector where each value is an element?. At the
moment the text file is just a single line of numbers (no decimal pint at
the start (e.g. 314159...etc).

Any pointers would be good. Sorry if this is basic one!

Thanks



--
Sent from: http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html



More information about the users mailing list