Introduction
Introduction Statistics Contact Development Disclaimer Help
timport_php_input.m - cosmo - front and backend for Markov-Chain Monte Carlo in…
git clone git://src.adamsgaard.dk/cosmo
Log
Files
Refs
README
LICENSE
---
timport_php_input.m (4287B)
---
1 %% Import data from text file.
2 % NOT USED! But kept in case it becomes useful later on.
3
4 % Script for importing data from the following text file:
5 %
6 % /tmp/cosmo_pgpzvt
7 %
8 % To extend the code to different selected data or a different text file,
9 % generate a function instead of a script.
10
11 % Auto-generated by MATLAB on 2015/08/24 12:46:56
12
13 %% Initialize variables.
14 filename = '/tmp/cosmo_pgpzvt';
15 delimiter = '\t';
16
17 %% Read columns of data as strings:
18 % For more information, see the TEXTSCAN documentation.
19 formatSpec = '%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%[^\…
20
21 %% Open the text file.
22 fileID = fopen(filename,'r');
23
24 %% Read columns of data according to format string.
25 % This call is based on the structure of the file used to generate this
26 % code. If an error occurs for a different file, try regenerating the co…
27 % from the Import Tool.
28 dataArray = textscan(fileID, formatSpec, 'Delimiter', delimiter, 'Retur…
29
30 %% Close the text file.
31 fclose(fileID);
32
33 %% Convert the contents of columns containing numeric strings to numbers.
34 % Replace non-numeric strings with NaN.
35 raw = repmat({''},length(dataArray{1}),length(dataArray)-1);
36 for col=1:length(dataArray)-1
37 raw(1:length(dataArray{col}),col) = dataArray{col};
38 end
39 numericData = NaN(size(dataArray{1},1),size(dataArray,2));
40
41 for col=[6,7,8,9,10,11,12,13,18,19,20,21,22,23,24,25,26,27]
42 % Converts strings in the input cell array to numbers. Replaced non-…
43 % strings with NaN.
44 rawData = dataArray{col};
45 for row=1:size(rawData, 1);
46 % Create a regular expression to detect and remove non-numeric p…
47 % suffixes.
48 regexstr = '(?<prefix>.*?)(?<numbers>([-]*(\d+[\,]*)+[\.]{0,1}\d…
49 try
50 result = regexp(rawData{row}, regexstr, 'names');
51 numbers = result.numbers;
52
53 % Detected commas in non-thousand locations.
54 invalidThousandsSeparator = false;
55 if any(numbers==',');
56 thousandsRegExp = '^\d+?(\,\d{3})*\.{0,1}\d*$';
57 if isempty(regexp(thousandsRegExp, ',', 'once'));
58 numbers = NaN;
59 invalidThousandsSeparator = true;
60 end
61 end
62 % Convert numeric strings to numbers.
63 if ~invalidThousandsSeparator;
64 numbers = textscan(strrep(numbers, ',', ''), '%f');
65 numericData(row, col) = numbers{1};
66 raw{row, col} = numbers{1};
67 end
68 catch me
69 end
70 end
71 end
72
73
74 %% Split data into numeric and cell columns.
75 rawNumericColumns = raw(:, [6,7,8,9,10,11,12,13,18,19,20,21,22,23,24,25,…
76 rawCellColumns = raw(:, [1,2,3,4,5,14,15,16,17]);
77
78
79 %% Allocate imported array to column variable names
80 sampleid = rawCellColumns(:, 1);
81 name = rawCellColumns(:, 2);
82 email = rawCellColumns(:, 3);
83 lat = rawCellColumns(:, 4);
84 long = rawCellColumns(:, 5);
85 be_conc = cell2mat(rawNumericColumns(:, 1));
86 al_conc = cell2mat(rawNumericColumns(:, 2));
87 c_conc = cell2mat(rawNumericColumns(:, 3));
88 ne_conc = cell2mat(rawNumericColumns(:, 4));
89 be_uncer = cell2mat(rawNumericColumns(:, 5));
90 al_uncer = cell2mat(rawNumericColumns(:, 6));
91 c_uncer = cell2mat(rawNumericColumns(:, 7));
92 ne_uncer = cell2mat(rawNumericColumns(:, 8));
93 be_prod = rawCellColumns(:, 6);
94 al_prod = rawCellColumns(:, 7);
95 c_prod = rawCellColumns(:, 8);
96 ne_prod = rawCellColumns(:, 9);
97 rock_density = cell2mat(rawNumericColumns(:, 9));
98 epsilon_gla_min = cell2mat(rawNumericColumns(:, 10));
99 epsilon_gla_max = cell2mat(rawNumericColumns(:, 11));
100 epsilon_int_min = cell2mat(rawNumericColumns(:, 12));
101 epsilon_int_max = cell2mat(rawNumericColumns(:, 13));
102 t_degla = cell2mat(rawNumericColumns(:, 14));
103 t_degla_uncer = cell2mat(rawNumericColumns(:, 15));
104 record = cell2mat(rawNumericColumns(:, 16));
105 record_threshold_min = cell2mat(rawNumericColumns(:, 17));
106 record_threshold_max = cell2mat(rawNumericColumns(:, 18));
107
108
109 %% Clear temporary variables
110
You are viewing proxied material from mx1.adamsgaard.dk. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.