MATLAB POLYSPACE RELEASE NOTES Manuel d'utilisateur Page 167

  • 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 166
Scripts and Functions
The function plot_f han dle, shown below, receives a function handle and
data, generates y-axis data using the function handle, and plots it:
function x = p lot_fhandle(fhandle , data)
plot(data, fhandle(data))
When you call plot_fhandle with a handle to the sin function and the
argument shown below, the resulting evaluation produces a sine wave plot:
plot_fhandle(@sin, -pi:0.0 1:pi)
Function Functions
A class of functions called “function functions” works with nonlinear functions
of a scalar variable. That is, one function works on another function. The
function functions include
Zero finding
Optimization
Quadrature
Ordinary differen tial equations
MATLAB represents the nonlinear function by a function M-file. For example,
here is a si mplified version of the function
humps from the matlab /dem os
directory:
function y = h umps(x)
y = 1./((x-.3).^2 + .01) + 1./((x-.9).^2 + . 04) - 6;
Evaluate this function at a set of points in the interval 0 x 1with
x = 0:.002:1;
y = humps(x);
Then plot the function with
plot(x,y)
4-29
Vue de la page 166
1 2 ... 162 163 164 165 166 167 168 169 170 171 172 ... 239 240

Commentaires sur ces manuels

Pas de commentaire