フィルターのクリア

How can I extract infroamtion from a header's file (text file)?

6 ビュー (過去 30 日間)
Alejandro Aguilar
Alejandro Aguilar 2015 年 6 月 5 日
回答済み: Radha Krishna Maddukuri 2015 年 6 月 9 日
I want extract information from a header file (see attachment). For instance I would like to save in an array or in variables the information such as, time, date, BeamVoltage, Filament, Temp, etc... so I can use these values later on or simply send them to a text box on a GUI.
I have tried several things but nothing really works for all since the format is not uniform at all, the information of interest sometimes comes after a ':' or a '=' or simple a ' '... Please help!!!.
Thanks, Alex

回答 (1 件)

Radha Krishna Maddukuri
Radha Krishna Maddukuri 2015 年 6 月 9 日
First of all, there is no direct ways for reading values with different delimiters like '=' ':' 'space', etc.,
However, readtable is a good function for reading the values that you intend to. The second example in the following documentation is relevant to your use case.
However a slight modification is required to your file.
For example: create a file A.txt:
Beam Voltage (-kV) = 13.000
Filament (W) = 4.052
Wehnelt (-V) = 400.00
Cond. (-kV) = 8.685
CenterX1 (V) = 23.7
CenterY1 (V) = -47.9
Objective (OctupoleX = 0.0000
OctupoleY = 0.0000
Angle (deg) = 0.00
Stig = 0.00
Then navigate to the folder containing A.txt in MATLAB and execute the following command in MATLAB Command Window:
>> readtable('A', 'delimiter', '=')
You will be able to read the required data.
For automating the modification of TEXT files, the following MATLAB Answer might be helpful.
I hope this helps you.

カテゴリ

Help Center および File ExchangeText Data Preparation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by