MATLAB POLYSPACE RELEASE NOTES Bedienungsanleitung Seite 169

  • Herunterladen
  • Zu meinen Handbüchern hinzufügen
  • Drucken
  • Seite
    / 240
  • Inhaltsverzeichnis
  • LESEZEICHEN
  • Bewertet. / 5. Basierend auf Kundenbewertungen
Seitenansicht 168
Scripts and Functions
Q = quadl(@humps,0,1)
computes the area under the curve in the graph and produces
Q=
29.8583
Finally, the graph shows that the function is never zero on this interval. So,
ifyousearchforazerowith
z = fzero(@humps,.5)
you will find one outside the interval
z=
-0.1316
Vectorization
One way to make your M ATLAB programs run faster is to vectorize the
algorithms you use in constructing the programs. Where other programming
languages might use
for loops or DO loops, MATLAB can use vector or matrix
operations. A simple example involves creating a table of logarithms:
x = .01;
for k = 1:1001
y(k) = log10(x);
x=x+.01;
end
A vectorized version of the same code is
x = .01:.01:10;
y = log10(x);
For more co mplicated code, vectorization options are not always so obv io us.
For More Information See “Improving Performan ce and Memo r y U sa ge
in the MATLAB Programming documentation for other techniques that you
can use.
4-31
Seitenansicht 168
1 2 ... 164 165 166 167 168 169 170 171 172 173 174 ... 239 240

Kommentare zu diesen Handbüchern

Keine Kommentare