Prev: Running max without for loop? The fastest way?
Next: Converting Certain Data from Numeric Matrix to Text
From: Bilal on 3 Jun 2010 15:02 Hey, I was hoping someone can help me out with a problem i'm having: i am trying to load a file in matlab, a sample of which is shown below: 15:03:21 II 0.88 0.64 15:03:21 II 0.82 0.64 15:03:21 II 0.40 ?.?? 15:03:21 II 0.38 0.40 etc.... the "load" function doesnt work because it reads the first two columns as ascii, so i import the data using the "import data" option under the file menu. My problem is that some of the data is corrupt and it shows up as ?.?? as can be seen above. Using the import data option, matlab will import the data from the begining of the file right up till where it sees '?.??' and then nothing after that. Does anyone know how i can import all the data, including the ?.??, and then go through the file to convert all the ?.?? into "0"? Bilal
From: Leslie McBrayer on 3 Jun 2010 16:05
> i am trying to load a file in matlab, a sample of which is shown below: > > 15:03:21 II 0.88 0.64 > 15:03:21 II 0.82 0.64 > 15:03:21 II 0.40 ?.?? > 15:03:21 II 0.38 0.40 etc.... > > Does anyone know how i can import all the data, including the ?.??, and > then go through the file to convert all the ?.?? into "0"? If all of the missing values appear in the file as "?.??", I would use the textscan function, like this: fid = fopen('myfile.dat'); mydata = textscan(fid, '%s %s %f %f', 'TreatAsEmpty', '?.??', 'EmptyValue', 0); fclose(fid); |