|
171 | 171 | end |
172 | 172 |
|
173 | 173 | function logFile = initializeFile(expParameters, logFile) |
| 174 | + |
| 175 | + createDataDictionary(expParameters, logFile); |
174 | 176 |
|
175 | 177 | logFile = initializeExtraColumns(logFile); |
176 | 178 |
|
@@ -214,36 +216,6 @@ function printHeaderExtraColumns(logFile) |
214 | 216 |
|
215 | 217 | end |
216 | 218 |
|
217 | | -function data = checkInput(data, expectedLength) |
218 | | - % check the data to write |
219 | | - % default will be 'n/a' for chars and NaN for numeric data |
220 | | - % for numeric data that don't have the expected length, it will be padded with NaNs |
221 | | - |
222 | | - if nargin < 2 |
223 | | - expectedLength = []; |
224 | | - end |
225 | | - |
226 | | - if ischar(data) && isempty(data) || strcmp(data, ' ') |
227 | | - data = 'n/a'; |
228 | | - elseif isempty(data) |
229 | | - % important to not set this to n/a as we still need to check if this |
230 | | - % numeric valur has the right length and needs to be nan padded |
231 | | - data = nan; |
232 | | - end |
233 | | - |
234 | | - if islogical(data) && data |
235 | | - data = 'true'; |
236 | | - elseif islogical(data) && ~data |
237 | | - data = 'false'; |
238 | | - end |
239 | | - |
240 | | - if ~isempty(expectedLength) && isnumeric(data) && max(size(data)) < expectedLength |
241 | | - padding = expectedLength - max(size(data)); |
242 | | - data(end + 1:end + padding) = nan(1, padding); |
243 | | - end |
244 | | - |
245 | | -end |
246 | | - |
247 | 219 | function logFile = checkExtracolumns(logFile, iEvent) |
248 | 220 | % loops through the extra columns |
249 | 221 | % if the field we are looking for does not exist or is empty in the |
@@ -277,6 +249,40 @@ function printHeaderExtraColumns(logFile) |
277 | 249 |
|
278 | 250 | end |
279 | 251 |
|
| 252 | +function data = checkInput(data, expectedLength) |
| 253 | + % check the data to write |
| 254 | + % default will be 'n/a' for chars and NaN for numeric data |
| 255 | + % for numeric data that don't have the expected length, it will be padded with NaNs |
| 256 | + |
| 257 | + if nargin < 2 |
| 258 | + expectedLength = []; |
| 259 | + end |
| 260 | + |
| 261 | + if islogical(data) && data |
| 262 | + data = 'true'; |
| 263 | + elseif islogical(data) && ~data |
| 264 | + data = 'false'; |
| 265 | + end |
| 266 | + |
| 267 | + |
| 268 | + if ischar(data) && isempty(data) || strcmp(data, ' ') |
| 269 | + data = 'n/a'; |
| 270 | + elseif isempty(data) |
| 271 | + % important to not set this to n/a as we still need to check if this |
| 272 | + % numeric valur has the right length and needs to be nan padded |
| 273 | + data = nan; |
| 274 | + end |
| 275 | + |
| 276 | + if ~isempty(expectedLength) && isnumeric(data) && max(size(data)) < expectedLength |
| 277 | + padding = expectedLength - max(size(data)); |
| 278 | + data(end + 1:end + padding) = nan(1, padding); |
| 279 | + elseif ~isempty(expectedLength) && isnumeric(data) && max(size(data)) > expectedLength |
| 280 | + data = data(1:expectedLength); |
| 281 | + warning('A field for this event is longer than expected. Truncating the extra values.') |
| 282 | + end |
| 283 | + |
| 284 | +end |
| 285 | + |
280 | 286 | function printExtraColumns(logFile, iEvent) |
281 | 287 | % loops through the extra columns and print them |
282 | 288 |
|
|
0 commit comments