Selecting text from a .txt file

1 visualización (últimos 30 días)
Drew
Drew el 23 de En. de 2013
Matlab users,
I have a question regarding selecting certain numbers from a .txt. Please see the following text and example.
The columns are the following from left to right: stimulus number, time in seconds, temperature, and a placeholder. In this paradigm, temperature maintains a baseline of around 41 degrees and there are four pulses of ~50 degrees within an ~18 second block of time (there are a total of four 18 second pulse trains per .txt file). I need to extract the time of first occurrence of 42.X degrees (onset) before the first ~50 degree pulse and the first occurrence of 41.X degrees (termination) after the fourth ~50 degree pulse. In the example (taken from a portion of a .txt file containing other information as well), those time values would be 32.08 and 50.53.
After extracting these values, I need to store each of the four onsets as a cell array variable and also store the difference between each onset and its respective termination as a cell array variable as well (in this case 50.53-32.08=18.45).
Does anyone have any suggestions on how I might be able to do this?
Many thanks!
Example data from .txt file: (The *'s were only included to aid in formatting for this post). For the fist line, 1=Stimulus number, 30.10=Time, and 40.8=temperature, the same pattern is retained for every line following.
  • 1 30.10 40.8 0
  • 1 30.21 40.8 0
  • 1 30.32 40.8 0
  • 1 30.43 40.8 0
  • 1 30.54 40.8 0
  • 1 30.65 40.8 0
  • 1 30.76 40.8 0
  • 1 30.87 40.8 0
  • 1 30.98 40.8 0
  • 1 31.09 41.0 0
  • 1 31.20 40.9 0
  • 1 31.31 40.9 0
  • 2 31.42 40.7 0
  • 2 31.53 40.7 0
  • 2 31.64 40.8 0
  • 2 31.75 40.9 0
  • 2 31.86 41.4 0
  • 2 31.97 41.8 0
  • 2 32.08 42.5 0
  • 2 32.19 43.4 0
  • 2 32.30 44.3 0
  • 2 32.41 44.8 0
  • 2 32.52 45.9 0
  • 2 32.63 46.8 0
  • 2 32.74 47.8 0
  • 2 32.85 48.2 0
  • 2 32.95 49.1 0
  • 2 33.06 49.3 0
  • 2 33.17 49.6 0
  • 2 33.28 49.7 0
  • 2 33.39 49.7 0
  • 2 33.50 49.4 0
  • 2 33.61 48.7 0
  • 2 33.72 48.4 0
  • 2 33.83 47.7 0
  • 2 33.94 46.8 0
  • 2 34.05 45.9 0
  • 2 34.16 45.5 0
  • 2 34.27 45.4 0
  • 2 34.38 43.7 0
  • 2 34.49 42.8 0
  • 2 34.60 42.8 0
  • 2 34.71 42.3 0
  • 3 34.82 40.8 0
  • 3 34.93 40.2 0
  • 3 35.04 40.2 0
  • 3 35.15 40.5 0
  • 3 35.26 41.4 0
  • 3 35.37 41.8 0
  • 3 35.48 42.8 0
  • 3 35.59 43.8 0
  • 3 35.70 44.3 0
  • 3 35.81 44.8 0
  • 3 35.92 46.3 0
  • 3 36.03 47.3 0
  • 3 36.14 48.1 0
  • 3 36.25 48.5 0
  • 3 36.36 49.2 0
  • 3 36.47 49.4 0
  • 3 36.58 49.7 0
  • 3 36.69 49.7 0
  • 3 36.80 49.5 0
  • 3 36.91 49.1 0
  • 3 37.02 48.5 0
  • 3 37.13 48.2 0
  • 3 37.24 47.4 0
  • 3 37.35 46.5 0
  • 3 37.46 45.7 0
  • 3 37.57 45.3 0
  • 3 37.68 44.8 0
  • 3 37.79 43.4 0
  • 3 37.90 42.4 0
  • 4 38.01 42.1 0
  • 4 38.12 41.5 0
  • 4 38.23 41.5 0
  • 4 38.34 41.0 0
  • 4 38.45 41.2 0
  • 4 38.56 42.0 0
  • 4 38.67 42.4 0
  • 4 38.78 43.4 0
  • 4 38.89 44.4 0
  • 4 39.00 45.5 0
  • 4 39.11 46.1 0
  • 4 39.22 47.1 0
  • 4 39.33 48.1 0
  • 4 39.44 49.0 0
  • 4 39.55 49.1 0
  • 4 39.66 49.5 0
  • 4 39.77 49.8 0
  • 4 39.88 49.7 0
  • 4 39.99 49.6 0
  • 4 40.10 49.0 0
  • 4 40.21 48.3 0
  • 4 40.31 47.5 0
  • 4 40.42 47.1 0
  • 4 40.53 46.3 0
  • 4 40.64 45.4 0
  • 4 40.75 44.5 0
  • 4 40.86 44.1 0
  • 4 40.97 44.0 0
  • 4 41.08 42.2 0
  • 5 41.19 41.7 0
  • 5 41.30 41.3 0
  • 5 41.41 41.1 0
  • 5 41.52 41.3 0
  • 5 41.63 42.0 0
  • 5 41.74 42.4 0
  • 5 41.85 43.4 0
  • 5 41.96 44.4 0
  • 5 42.07 45.5 0
  • 5 42.18 46.5 0
  • 5 42.29 47.0 0
  • 5 42.40 48.0 0
  • 5 42.51 48.9 0
  • 5 42.62 49.3 0
  • 5 42.73 49.0 0
  • 5 42.84 49.8 0
  • 5 42.95 50.0 0
  • 5 43.06 50.0 0
  • 5 43.17 49.8 0
  • 5 43.28 49.3 0
  • 5 43.39 48.6 0
  • 5 43.50 47.8 0
  • 5 43.61 47.4 0
  • 5 43.72 46.5 0
  • 5 43.83 45.6 0
  • 5 43.94 44.6 0
  • 5 44.05 44.1 0
  • 5 44.16 43.2 0
  • 5 44.27 42.2 0
  • 6 44.38 41.7 0
  • 6 44.49 40.7 0
  • 6 44.60 40.4 0
  • 6 44.71 40.8 0
  • 6 44.82 41.6 0
  • 6 44.93 42.2 0
  • 6 45.04 43.3 0
  • 6 45.15 44.3 0
  • 6 45.26 45.4 0
  • 6 45.37 45.9 0
  • 6 45.48 46.9 0
  • 6 45.59 47.9 0
  • 6 45.70 48.8 0
  • 6 45.81 49.2 0
  • 6 45.92 49.4 0
  • 6 46.03 49.8 0
  • 6 46.14 50.0 0
  • 6 46.25 49.9 0
  • 6 46.36 49.6 0
  • 6 46.47 49.0 0
  • 6 46.58 48.4 0
  • 6 46.69 48.0 0
  • 6 46.80 47.1 0
  • 6 46.91 46.2 0
  • 6 47.02 45.3 0
  • 6 47.13 45.3 0
  • 6 47.24 43.9 0
  • 6 47.35 43.0 0
  • 7 47.46 42.1 0
  • 7 47.57 41.5 0
  • 7 47.67 41.3 0
  • 7 47.78 41.6 0
  • 7 47.89 42.2 0
  • 7 48.00 42.6 0
  • 7 48.11 43.5 0
  • 7 48.22 44.5 0
  • 7 48.33 45.5 0
  • 7 48.44 46.0 0
  • 7 48.55 47.0 0
  • 7 48.66 47.9 0
  • 7 48.77 48.7 0
  • 7 48.88 49.2 0
  • 7 48.99 49.4 0
  • 7 49.10 49.7 0
  • 7 49.21 49.9 0
  • 7 49.32 49.8 0
  • 7 49.43 49.7 0
  • 7 49.54 49.0 0
  • 7 49.65 48.3 0
  • 7 49.76 47.5 0
  • 7 49.87 47.4 0
  • 7 49.98 46.1 0
  • 7 50.09 45.3 0
  • 7 50.20 44.3 0
  • 7 50.31 43.8 0
  • 7 50.42 42.9 0
  • 8 50.53 41.9 0
  • 8 50.64 41.4 0
  • 8 50.75 40.6 0
  • 8 50.86 40.1 0
  • 8 50.97 40.2 0
  • 8 51.08 40.2 0
  • 8 51.19 40.0 0
  • 8 51.30 40.2 0
  • 8 51.41 40.6 0
  • 8 51.52 40.8 0
  • 8 51.63 40.8 0

Respuestas (1)

Matt Kindig
Matt Kindig el 23 de En. de 2013
Hi Drew,
First, you just need to import the data from the file into Matlab. Easy enough:
data = dlmread('/path/to/your/file.txt', ' '); %read in file
temperature = data(:,3); %temperature data
Now you need to identify in temperature your pulses. I'm afraid I don't understand your "pulse" definition-- from the data you posted the temperature never exceeds 50 degrees. Can you clarify (and perhaps post some data that contains a pulse)?
  1 comentario
Drew
Drew el 23 de En. de 2013
Matt,
Thank you for your reply. Temperature is only sampled every .11 seconds, so 50 degrees is not always recorded. It may record 49.6, 49.8 etc as the top of the pulse. For example, the beginning of one pulse would be at 32.08 and the end of this one pulse is 35.04 with a peak of 49.7 degrees.
The data above contains 4 pulses, making one complete train. Does this help?

Iniciar sesión para comentar.

Categorías

Más información sobre MATLAB en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by