home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l460 / 2.ddi / LANG.DI$ / EVAL.M < prev    next >
Encoding:
Text File  |  1993-03-07  |  1.4 KB  |  50 lines

  1. %EVAL    Execute string containing MATLAB expression.
  2. %    EVAL(s), where s is a string, causes MATLAB to execute
  3. %    the string as an expression or statement.
  4. %
  5. %    EVAL(s1,s2) provides the ability to catch errors.  It
  6. %    executes string s1 and returns if the operation was
  7. %    successful. If the operation generates an error,
  8. %    string s2 is evaluated before returning. Think of this
  9. %    as EVAL('try','catch')
  10. %    
  11. %    [X,Y,Z,...] = EVAL(s) returns output arguments from the
  12. %    expression in string s.
  13. %
  14. %    The input strings to EVAL are often created by 
  15. %    concatenating substrings and variables inside square
  16. %    brackets. For example:
  17. %
  18. %    Generate a sequence of matrices named M1 through M12:
  19. %
  20. %        for n = 1:12
  21. %           eval(['M' num2str(n) ' = magic(n)'])
  22. %        end
  23. %
  24. %    Run a selected M-file script.  The strings making up 
  25. %    the rows of matrix D must all have the same length.
  26. %    
  27. %        D = ['odedemo '
  28. %             'quaddemo'
  29. %             'fitdemo '];
  30. %        n = input('Select a demo number: ');
  31. %        eval(D(n,:))
  32. %
  33. %    Read and process files with names data1.dat, data2.dat, ...
  34. %
  35. %        k = 0;
  36. %        while 1
  37. %           k = k+1;
  38. %           datak = ['data' int2str(k)];
  39. %           filename = [datak '.dat'];
  40. %           if ~exist(filename), break, end
  41. %           eval(['load ' filename]);
  42. %           X = eval(datak);
  43. %           % Process data in matrix X.
  44. %        end
  45. %
  46. %    See also LASTERR, FEVAL.
  47.  
  48. %    Copyright (c) 1984-93 by The MathWorks, Inc.
  49. %    Built-in function.
  50.