To create an array non rectangular, and replace -9.99e+08 by NaN
25 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
With an ascii file like this, i should create an array without char and replace -9.99e+08 by NaN. I have tried to use fscaf, importdata, fopen, fgetl, textscan, with no luck. Data is about 2700x120
DAY 1
hora
2.94661,2.8992,2.83784,2.75326,2.64293,2.502,2.33672,2.15181,1.97694,1.62358,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,0.00668253,0.0327668,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,0.382449,0.634328,0.756799,2.02886,2.02872,2.0448,2.08052,2.13473,2.19808,2.26112,2.32166,2.38032,2.43497,2.49194,2.55233,2.61536,2.6884,2.75805,2.82604,2.89104,2.94754,2.99919,3.04897,3.09346,3.12746,3.15073,3.17229,3.18993,3.21008,3.21896,3.21751,3.21407,3.2092,3.19818,3.17865,3.15254,3.12281,3.09062,3.05499,
DAY 1
hora
3.01386,2.95982,2.89613,2.79949,2.66645,2.51039,2.31493,2.08688,1.88495,1.69834,1.21471,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,0.113704,0.686638,0.838769,1.94775,1.98941,2.01369,2.04883,2.10897,2.17141,2.23687,2.30698,2.36559,2.41933,2.47953,2.5397,2.61365,2.69031,2.76852,2.84643,2.91943,2.98375,3.04899,3.10675,3.15609,3.19145,3.22043,3.252,3.27625,3.30003,3.30994,3.30678,3.30493,3.29936,3.28458,3.25814,3.22225,3.1828,3.13889,
DAY 1
hora
3.09121,3.03496,2.95881,2.8708,2.70711,2.52024,2.28281,2.03823,1.78428,1.55195,1.22014,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,-9.99e+08,0.375232,1.83988,1.902,1.96085,2.01703,2.07893,2.14457,2.21195,2.27242,2.32602,2.38688,2.45014,2.5231,2.6051,2.68827,2.77123,2.85808,2.94469,3.02391,3.09252,3.15477,3.21066,3.25666,3.3011,3.34646,3.37945,3.40107,3.40978,3.41064,3.40967,3.39793,3.37444,3.33646,3.28961,3.23557,
. . .
clear all;
contador=1;
fid = fopen('ascii_file.txt');
tline = fgetl(fid);
while ischar(tline)
disp(tline)
tline = fgetl(fid);
if (tline ~= -1)
nums(contador,:) = sscanf(tline(:), [1, inf]);
end
contador = contador + 1;
end
fclose(fid);
1 commentaire
Stephen23
le 15 Juin 2016
@Rapha alpha: can you please edit your question and upload a sample file using the paperclip button. This makes helping you much easier.
Réponses (1)
Shameer Parmar
le 15 Juin 2016
Hello Rapha alpha,
Try for this code..
clear all;
contador=1;
fid = fopen('ascii_file.txt');
tline = fgetl(fid);
while ischar(tline)
disp(tline);
if (tline ~= -1)
if ~isempty(tline)
nums(contador,:) = {strrep(tline,'-9.99e+08','NaN')};
end
else
nums(contador,:) = {''};
end
contador = contador + 1;
tline = fgetl(fid);
end
fclose(fid);
fid = fopen('ascii_file.txt','w');
for i=1:length(nums)
fprintf(fid,'%s\n',nums{i});
end
fclose(fid);
0 commentaires
Voir également
Catégories
En savoir plus sur Genomics and Next Generation Sequencing dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!