from
Test Tools - Utilities for unit tests
by Jay St. Pierre
Tools that facilitate debugging or writing unit test for MATLAB functions.
|
| set_val(var_name, expression, workspace) |
function set_val(var_name, expression, workspace)
%SET_VAL nicely displays a variable assignment.
% SET_VAL(var_name, expression) assigns the result of the
% expression to the named variable.
% SET_VAL(var_name, expression, WS) is performed in the workspace
% specified by WS. At this time, only 'base' and 'caller' are valid
% workspaces. The default workspace is 'caller'.
% $Source: /home/stpierre/cvsroot/matlab/tools/test_tools/set_val.m,v $
% $Revision: 1.3 $
% $Date: 2009-07-26 20:41:24 $
% Copyright (c) 2000-2009, Jay A. St. Pierre. All rights reserved.
if nargin~=2
error('set_value() requires at least two input arguments')
elseif ~ischar(var_name)
error('first input must be a string (try quoting the input expression)')
elseif ~ischar(expression)
error('second input must be a string (try quoting the input expression)')
end
if nargin==2
workspace='caller';
end
disp([var_name, ' = ', expression, 10])
evalin(workspace, [var_name, ' = ', expression, ';'])
|
|
Contact us at files@mathworks.com