How to read text table with value in scientific notation and column headers?
5 ビュー (過去 30 日間)
古いコメントを表示
Pedro Andre Viegas Ochoa de Carvalho
2017 年 1 月 27 日
Hello all,
I have a text file (in attachment) made of columns with column headers and scientific notation values. I would like to extract only the numeric content from each column, and keep the data from each column in different variables. I have tried to extract the content with the 'readtable' function, using different options but always without success. I suspect one of the problems might be because of the fact that the data is originally stored in scientific notation (which I cannot avoid). Can anybody help me, please?
Thank you very much. Regards, Pedro Ochoa
0 件のコメント
採用された回答
KSSV
2017 年 1 月 27 日
data = importdata('NEW_Val_2_Trial_3_Run_1_UTdata.txt') ;
num_data = data.data ;
X = num_data(:,1) ;
data1 = num_data(:,2) ;
data2 = num_data(:,3) ; % like wise other data's
plot(X,data1) ;
0 件のコメント
その他の回答 (2 件)
Guillaume
2017 年 1 月 27 日
編集済み: Guillaume
2017 年 1 月 27 日
The problem with readtable is nothing to do with scientific notation. Matlab copes with that with no problem. The problem is that your file contains two tables, the second one starting at line 15008.
Note that KSSV's answer that you've accepted only loads the first of these tables. Values from line 15008 to 30018 are not loaded.
Here is a way to read the whole file (ignoring headers):
fid = fopen('NEW_Val_2_Trial_3_Run_1_UTdata.txt', 'rt');
matrices = {}; %cell array that will hold all the matrices in your file
while ~feof(fid);
currentmat = cell2mat(textscan(fid, repmat('%f', 1, 7)));
if isempty(currentmat)
fgetl(fid);
else
matrices{end+1} = currentmat; %#OK<AGROW>
end
end
fclose(fid);
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Workspace Variables and MAT Files についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!