Friday, 15 August 2014

matlab : permutation of two lists based on criteria -



matlab : permutation of two lists based on criteria -

i hope can help me, how accomplish this. have files list of data, trying calculate possible permutations between 2 lists , save them new file. realized output file big ( more 30 gb ). know how create permutation between info meets specific criteria. f.eks if :

data 1: vhxbxvvxpx255x98x info 2: vhxbxvvxpx255x98x

only permutate if char(6 , 7) data1 = char(6 , 7) data2.

my code far :

fid = fopen( 'file1.txt' ); cac = textscan( fid, '%20s' ); fclose( fid ); num = cac{1}; fid = fopen( 'file2.txt' ); cac = textscan( fid, '%20s' ); fclose( fid ); str = cac{1}; fid = fopen( 'file3.txt', 'w' ); ii = 1 : length( num ) jj = 1 : length( str ) fprintf( fid, '%1s - %1s\n', num{ii}, str{jj} ); end end fclose( fid );

you can utilize

clear all; fid = fopen( 'file1.txt' ); cac = textscan( fid, '%20s' ); num = cac{1}; fclose( fid ); fid = fopen( 'file2.txt' ); cac = textscan( fid, '%20s' ); str = cac{1}; fclose( fid ); fid = fopen( 'file3.txt', 'w' ); inum = 1 : size(num,1) inxmcells = cellfun(@(x) strcmp(x(6:7), num{inum}(6:7)), str,'uniformoutput', false); %[0,1] index of (non)matching cells mcells = str(logical(cell2mat(inxmcells))); j = 1 : length( mcells ) fprintf( fid, '%1s - %1s\n', num{inum}, mcells{j} ); end end fclose( fid );

matlab permutation criteria readfile writefile

No comments:

Post a Comment