[scilab-Users] Re: uploading a file txt

CRETE Denis denis.crete at thalesgroup.com
Tue Jul 5 15:06:56 CEST 2011


Hello,
After reading the file and assigned the content to M, in order to reject the first 15 lines when a change occurs in column 7 and at the very start, you can do:

change=[0,find(M(1:$-1,7)~=M(2:$,7))];
first15=matrix((1:15)'*ones(change)+ones(15,1)*change,-1,1);
M(first15,:)=[];

// to save it, may be
this_dir=get_absolute_file_path('this_script.sce');
// and then
chdir this_dir;
// finally
// The name of the matrix to save in the MNew.txt file has been ommitted !
fprintfMat('Mnew.txt',M);

Regards
Denis

-----Message d'origine-----
De : Chiara [mailto:chi.venier at gmail.com] 
Envoyé : mardi 5 juillet 2011 13:46
À : users at lists.scilab.org
Objet : [scilab-Users] Re: uploading a file txt

It doesn't work, but maybe I wrongly write the fprintfMat syntax.
My script is as follows:

fd=mopen('file.txt'); 
M=mfscanf(-1,fd,"%f %f %f %f %f %f %f\n"); 
stacksize('max')
gstacksize('max')
mclose(fd); 

data=M(:,1);

for i=2:length(data)-1
    if  M(i,7)~=M(i-1,7);
        M(i,8)=%nan;
        M(i+1,8)=%nan;
        M(i+2,8)=%nan;
        M(i+3,8)=%nan;
        M(i+4,8)=%nan;
        M(i+5,8)=%nan;
        M(i+6,8)=%nan;
        M(i+7,8)=%nan;
        M(i+8,8)=%nan;
        M(i+9,8)=%nan;
        M(i+10,8)=%nan;
        M(i+11,8)=%nan;
        M(i+12,8)=%nan;
        M(i+13,8)=%nan;
        M(i+14,8)=%nan;
    end
end

M(1:15,8)=%nan;

Mnew=M;

Mnew(or(isnan(Mnew)'),:) = [];
fprintfMat(TMPDIR + '/Mnew.txt');



Is it possible to save the matrix Mnew in the directory where I am working?
Thanks for help

Chiara



--
View this message in context: http://mailinglists.scilab.org/uploading-a-file-txt-tp3090694p3140486.html
Sent from the Scilab users - Mailing Lists Archives mailing list archive at Nabble.com.



More information about the users mailing list