Time for an 2014 update…

This commit is contained in:
Ingy döt Net 2014-01-17 05:32:22 +00:00
parent 372c577f83
commit 09687c4926
2520 changed files with 34227 additions and 7318 deletions

View file

@ -1,20 +1,15 @@
% Is string numeric?
function [out] = str_isnumeric(string)
if ~ischar(string)
error('str_isnumeric:NonCharacterArray','not a string input');
% Is string numeric?
function out = is_str_numeric(s)
out = ~isempty(parse_float(s));
end
Nd = sum(isstrprop(string,'digit'));
Nc = length(string);
dN = Nc - Nd;
switch dN
case 0
out = 1;
otherwise
out = 0;
% Returns the float (double) if true, empty array otherwise.
function f = parse_float(s)
[f_in_cell, pos] = textscan(s, '%f');
% Make sure there are no trailing chars. textscan(..) is greedy.
if pos == length(s)
f = f_in_cell{:};
else
f = [];
end
end
end