Skip to content

Commit

Permalink
Add missing utilities
Browse files Browse the repository at this point in the history
  • Loading branch information
alxhslm committed Jan 16, 2021
1 parent 32329f9 commit 4a27c98
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Utilities/L2norm.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
function y = L2norm(x,dim)
if nargin < 2
dim = 1;
end
y = sqrt(sum(abs(x).^2,dim));
21 changes: 21 additions & 0 deletions Utilities/filename.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
function [file,ext] = filename(str)
if iscell(str)
if nargout > 1
for i = 1:length(str)
[file{i},ext{i}] = filename(str{i});
end
else
for i = 1:length(str)
file{i} = filename(str{i});
end
end
return
end

[~,file,ext] = fileparts(str);

if nargout < 2
if ~isempty(ext)
file = [file ext];
end
end
13 changes: 13 additions & 0 deletions Utilities/moddate.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
function datenum = moddate(file)
if iscell(file)
for i = 1:length(file)
datenum(i) = moddate(file{i});
end
return
end
path = fileparts(file);
if isempty(path)
file = which(file);
end
d = dir(file);
datenum = d.datenum;
5 changes: 5 additions & 0 deletions Utilities/normalise.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
function y = normalise(x,dim)
if nargin < 2
dim = 1;
end
y = x ./L2norm(x,dim);

0 comments on commit 4a27c98

Please sign in to comment.