Mercurial > hg > octave-lyh
comparison scripts/io/strread.m @ 12873:e8c8e118a1e6
Small touchups to textscan and strread revamp
* textscan.m: Stop passing headerlines option to strread.
* strread.m: Use str2double, not str2num, for better performance.
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Fri, 22 Jul 2011 16:47:40 -0700 |
parents | fe6e2afcd9ee |
children | ddea3962b024 |
comparison
equal
deleted
inserted
replaced
12872:031e1a2c26f3 | 12873:e8c8e118a1e6 |
---|---|
527 endif | 527 endif |
528 varargout{k} = data.'; | 528 varargout{k} = data.'; |
529 k++; | 529 k++; |
530 case {"%0", "%1", "%2", "%3", "%4", "%5", "%6", "%7", "%8", "%9"} | 530 case {"%0", "%1", "%2", "%3", "%4", "%5", "%6", "%7", "%8", "%9"} |
531 nfmt = strsplit (fmt_words{m}(2:end-1), '.'); | 531 nfmt = strsplit (fmt_words{m}(2:end-1), '.'); |
532 swidth = str2num (nfmt{1}); | 532 swidth = str2double (nfmt{1}); |
533 switch fmt_words{m}(end) | 533 switch fmt_words{m}(end) |
534 case {"d", "u", "f", "n%"} | 534 case {"d", "u", "f", "n%"} |
535 n = cellfun ("isempty", data); | 535 n = cellfun ("isempty", data); |
536 ### FIXME - erroneously formatted data lead to NaN, not an error | 536 ### FIXME - erroneously formatted data lead to NaN, not an error |
537 ### => ReturnOnError can't be implemented for numeric data | 537 ### => ReturnOnError can't be implemented for numeric data |
539 data(n) = numeric_fill_value; | 539 data(n) = numeric_fill_value; |
540 if (pad_out) | 540 if (pad_out) |
541 data(end+1:num_lines) = numeric_fill_value; | 541 data(end+1:num_lines) = numeric_fill_value; |
542 endif | 542 endif |
543 if (numel (nfmt) > 1) | 543 if (numel (nfmt) > 1) |
544 sprec = str2num (nfmt{2}); | 544 sprec = str2double (nfmt{2}); |
545 data = 10^-sprec * round (10^sprec * data); | 545 data = 10^-sprec * round (10^sprec * data); |
546 endif | 546 endif |
547 varargout{k} = data.'; | 547 varargout{k} = data.'; |
548 k++; | 548 k++; |
549 case "s" | 549 case "s" |