from
Test Tools - Utilities for unit tests
by Jay St. Pierre
Tools that facilitate debugging or writing unit test for MATLAB functions.
|
| disp_value(string, workspace) |
function disp_value(string, workspace)
% DISP_VALUE nicely displays an expression and its value.
% By default, the caller workspace is used to evaluate the expression.
% To specify a different workspace, use: DISP_VALUE(expression,
% workspace) At the time this function was written, the only two valid
% workspace specifications were 'base' and 'caller'.
%
% For example, if A=1:2, then DISP_VALUE('A.''') produces:
%
% A.' =
% 1
% 2
% $Source: /home/stpierre/cvsroot/matlab/tools/test_tools/disp_value.m,v $
% $Revision: 1.5 $
% $Date: 2009-07-26 20:41:24 $
% Copyright (c) 2000-2009, Jay A. St. Pierre. All rights reserved.
if ~ischar(string)
error('input must be a string (try quoting the input expression)')
end
if nargin==1
workspace='caller';
end
value=evalin(workspace, string);
if(min(size(value))==1)
disp([string, ' ='])
for n=1:size(value,1)
disp([' ', num2str(value(n,:))])
end
else
disp(['value = ',string])
value %#ok<NOPRT>
end
|
|
Contact us at files@mathworks.com