フィルターのクリア

How to break down a text file

2 ビュー (過去 30 日間)
jgillis16
jgillis16 2015 年 6 月 21 日
コメント済み: Azzi Abdelmalek 2015 年 6 月 21 日
I need to break down a text file into its respective columns. It has 6 columns. Would I format the code along the lines of something like this?
s271.1_hD = readCatalog(s27WHW02_LS220_j0_rx3_full_cc_fheat1.1_hD)
fid = fopen( 's27WHW02_LS220_j0_rx3_full_cc_fheat1.1_hD.txt');
data = textscan(fid, '%s', 'Delimiter', '\n', 'whitespace','');
fclose(fid);
list.time = data{1};
list.h+eq = data{2};
list.hxeq = data{3};
list.h+p = data{4};
list.hxp = data{5};
list.rho_c = data{6};
return
My file I need to break down is attached. Thank you!
  1 件のコメント
per isakson
per isakson 2015 年 6 月 21 日
編集済み: per isakson 2015 年 6 月 21 日
I assume you want to convert to double. Try to replace
data = textscan(fid, '%s', 'Delimiter', '\n', 'whitespace','');
by
data = textscan( fid, '%f%f%f%f%f%f' );

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

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2015 年 6 月 21 日
編集済み: Azzi Abdelmalek 2015 年 6 月 21 日
You can use dlmread function
M=dlmread('s27WHW02_LS220_j0_rx3_full_cc_fheat1.1_hD.txt')
list=cell2struct(num2cell(M),{'f1' ,'f2','f3','f4','f5' ,'f6'},2)
  2 件のコメント
jgillis16
jgillis16 2015 年 6 月 21 日
How would I assign a variable to a specific column in 'M'? Say I wanted to assign X1 to the first column?
Azzi Abdelmalek
Azzi Abdelmalek 2015 年 6 月 21 日

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

その他の回答 (0 件)

カテゴリ

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