[Scilab-users] [EXTERNAL] Count specific values in text file

Carrico, Paul paul.carrico at auxitrolweston.com
Tue Feb 11 13:58:14 CET 2020


Hi

Is that what you're expecting i.e. a way to reshape your matrix among other things ?

Paul
##################################################
mode(0)
A=[1 2 3 4 5 6 7 8 9 1 1 1 1 1 1 4 4 5 5 5 5 8 8];

loc = find(A == 1);
occ = size(loc, "*");
printf("Number of occurences = %d",occ);

// reshaping
B=[1 2 3 4 5 6 7 8 9 1 1 1 ;
   1 1 1 4 4 5 5 5 5 8 8 0];
[n,m] = size(B);
C = matrix(B,(n*m),1);

// then look for your specific values



-----Message d'origine-----
De : users [mailto:users-bounces at lists.scilab.org] De la part de arctica1963
Envoyé : mardi 11 février 2020 13:11
À : users at lists.scilab.org
Objet : [EXTERNAL] [Scilab-users] Count specific values in text file

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: https://urldefense.com/v3/__http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html__;!!Cn2zSGkVug!dS2Fn2dKbFa5OF5GfEkOTNYlP5qA1dPf0ClsKnbfRbq7V6EWja6b9vP-OaWfFOX5zIqjbi3g$ 
_______________________________________________
users mailing list
users at lists.scilab.org
https://urldefense.com/v3/__http://lists.scilab.org/mailman/listinfo/users__;!!Cn2zSGkVug!dS2Fn2dKbFa5OF5GfEkOTNYlP5qA1dPf0ClsKnbfRbq7V6EWja6b9vP-OaWfFOX5zLxxkxMH$ 



More information about the users mailing list