フィルターのクリア

Reading particular values from a *.txt file and saving

1 回表示 (過去 30 日間)
Cyros
Cyros 2014 年 7 月 14 日
コメント済み: Cyros 2014 年 7 月 14 日
hi folks,
the file i've got has this format:
DATA
PIPE MEDIUM | MASS-FLOW MOLE-FLOW VOL-FLOW | PRESSURE
NO TYPE | [kg/s] [kmol/s] [m3/s] | [bar]
1 GASMIX | 0.00156 0.00005 0.00085 | 1.0000
| 0.00085 | 1.0000
2 GASMIX | 0.00156 0.00005 0.00415 | 1.0000
| 0.00415 | 1.0000
3 GASMIX | 0.00178 0.00007 0.00927 | 1.0000
VOLTAGE/CELL = 0.8000 [V]
CURRENT DENSITY = 3504.80 [A/m2]
DC-POWER = 1.6748 [kW]
AC-POWER = 1.5074 [kW]
i need to read the values of massflow of pipe nr.1 and of the ac-power. after that i need to save the values in a table after each run.
any ideas? thanks cyros

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2014 年 7 月 14 日
fid = fopen('file.txt');
str={};
while ~feof(fid)
str{end+1,1}=regexp(fgetl(fid),'(?<= \|).+(?=\|)','match')
end
fclose(fid);
str(cellfun(@isempty,str))=[]
str=str(3:end)
str=str(1:2:end)
a=cell2mat(cellfun(@(x) str2num(x{1}),str,'un',0))
out=a(:,1)
  1 件のコメント
Cyros
Cyros 2014 年 7 月 14 日
thanks, tha's a good start i guess. it gives me the value of pipe nr. 3, i need pipe nr. 1 and dc power.
i will have to work it.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by