Commit f25e9dea authored by Jesse Heckman's avatar Jesse Heckman
Browse files

update utilities / math

parent 1903593c
......@@ -14,7 +14,7 @@ function pb_clean(varargin)
if fig; close all; end
if empty; clc; end
if clr; evalin('base','clear'); end
if clr; pb_clear; end
end
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
......
function pb_clear(varargin)
% PB_CLEAR(varargin)
%
% PB_CLEAR() clears the base workspace with the exception of variables
% passed along to varargin.
%
% See also PB_CLEAN
% PBToolbox (2018): JJH: j.heckman@donders.ru.nl
list = evalin('base', 'who');
listsz = length(list);
listArr = 1 : listsz;
keep = varargin';
keepsz = length(keep);
for iKeep = 1 : keepsz
var = keep{iKeep};
idx = find(strcmp(list,var));
if ~isempty(idx)
list = list(listArr(listArr~=idx));
listsz = length(list);
listArr = 1:listsz;
end
end
listsz = length(list);
if listsz > 0
baseCommand = 'clear(';
for iClear = 1 : listsz
baseCommand = [baseCommand '''' list{iClear} ''''];
if iClear < listsz
baseCommand = [baseCommand ','];
else
baseCommand = [baseCommand ')'];
end
end
evalin('base', baseCommand)
end
end
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
% %
% Part of Programmeer Beer Toolbox (PBToolbox) %
% Written by: Jesse J. Heckman (2018) %
% %
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
......@@ -16,7 +16,7 @@ function pb_delete(varargin)
len = length(h);
for iH = 1:len
if contains(h(iH).Type,'Axes') || contains(h(iH).Type,'Figure')
if contains(h(iH).Type,'axes') || contains(h(iH).Type,'figure')
cnt = cnt+1;
end
end
......
function c = pb_pythagoras(a,b)
% PB_PYTHAGORAS(a,b)
%
% PB_PYTHAGORAS(a,b) ...
%
% See also ...
% PBToolbox (2018): JJH: j.heckman@donders.ru.nl
if mean(a)<0; sign = -1; else; sign = 1; end
if mean(b)<0; sign = -1 * sign; end
c = sqrt(a.^2 + b.^2) * sign;
end
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
% %
% Part of Programmeer Beer Toolbox (PBToolbox) %
% Written by: Jesse J. Heckman (2018) %
% %
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment