MATLAB POLYSPACE RELEASE NOTES Manuel d'utilisateur Page 159

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 240
  • Table des matières
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 158
Scripts and Functions
If you duplicate function names, MATLAB executes the one that o ccurs first
in the search path.
To view the contents of an M-file, for example,
myfunction.m,use
type myfunction
Scripts
When you i nvoke a script, MATLAB simply executes the comm ands found in
thefile. Scriptscanoperateonexisting data in the workspace, or they can
create new data on which to operate. Although scripts do not return output
arguments, any variables that they create remain in the workspace, to be
used in subsequent computations. In a ddition, scripts can produce graphical
output using functions like
plot.
For exam ple, create a file called
magicrank.m that contains these MATLAB
commands:
% Investigate the rank of mag ic squares
r = zeros(1,32);
for n = 3:32
r(n) = rank(magic(n));
end
r
bar(r)
Typing the statement
magicrank
causes M ATLAB to execute the commands, compute the rank of the first 30
magic squares, and plot a bar graph of the result. After execution of the file is
complete, the variables
n and r remain in the workspace.
4-21
Vue de la page 158
1 2 ... 154 155 156 157 158 159 160 161 162 163 164 ... 239 240

Commentaires sur ces manuels

Pas de commentaire