Created
August 6, 2017 21:01
-
-
Save yuchung-chuang/e0e508ecd8d702ce03a5589fe614dc68 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function obj = varassign( obj, var ) | |
if nargin < 2 || isempty(var) | |
return | |
end | |
nvarin = numel(var); | |
assert( ~mod( nvarin, 2 ), 'Field and value input arguments must come in pairs.' ); | |
for i = 1:2:nvarin-1 | |
mc = metaclass(obj); | |
[~, LocB] = ismember(lower(var{i}),lower({mc.PropertyList.Name})); | |
obj.(mc.PropertyList(LocB).Name) = var{i+1}; | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment