MATLAB POLYSPACE RELEASE NOTES Instrukcja Użytkownika Strona 163

  • Pobierz
  • Dodaj do moich podręczników
  • Drukuj
  • Strona
    / 240
  • Spis treści
  • BOOKMARKI
  • Oceniono. / 5. Na podstawie oceny klientów
Przeglądanie stron 162
Scripts and Functions
other M-files) while subfunctions cannot. Subfunctions are visible only to the
primary function and other subfunctions within their own M-file.
The
rank functionshowninthesectionon“Functions”onpage4-22isan
example of a primary function.
Private Functions
A private function is a type of primary M-file function. Its unique
characteristic is that it is visible only to a limited group of other functions.
This type of function can be useful if you want to limit access to a function, or
when you choose not to expose the implementation of a function.
Private functions reside in s ubdirectories with the special name
private.
They are visible on ly to functions in the p a rent directory. For ex ample,
assume the directory
newmath is on the MATLAB search path. A subdirectory
of
newmath called private can contain functions that only the functions in
newmath can call.
Because private functions are invisible outside the parent directory, they can
use the same names as functions in other directories. This is useful if you
want to create your own version of a particula r function wh ile retai n ing the
origina l in another dir ectory. Because MATLAB looks for private functi ons
before standard M-file functions, it will find a private function named
test.m
before a nonprivate M-file named test.m.
Nested Functions
You can define functions w ithin the body of any M ATLAB M-file function.
These are said to be nested within the outer function. A nested function
contains any or all of the components of any other M-file function. In this
example, function
B is nested in function A:
function x = A (p1, p2)
...
B(p2)
function y = B (p3)
...
end
...
end
4-25
Przeglądanie stron 162
1 2 ... 158 159 160 161 162 163 164 165 166 167 168 ... 239 240

Komentarze do niniejszej Instrukcji

Brak uwag