MATLAB COMPILER RELEASE NOTES Guide de l'utilisateur Page 165

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 264
  • Table des matières
  • DEPANNAGE
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 164
Print Handlers
5-49
mrank.m determines the rank of the magic squares from 1 to n.
function r = mrank(n)
r = zeros(n, 1);
for k = 1:n
r(k) = rank(magic(k));
end
myph.c contains the print handler and the print handler initialization
routine, in that order. In the example, this C file is written by the user.
#include "matlab.h"
#include “mr_external.h”
static void myPrintHandler(const char *s)
{
printf("%s\n",s);
}
void Mmr_initprnt(void)
{
mlfSetPrintHandler(myPrintHandler);
}
Writing the Print Handler in C/C++
First, write a print handler in C following the standard rules for a print
handler: it must take one argument of type
const char *s and return void.
The p rint handler in this e xample is very simple.
static void myPrintHandler(const char *s)
{
printf("%s\n",s);
}
The file myph.c contains this code.
Registering the Print Handler
Registering the print handler requires several steps, some performed in C and
some in M. Be careful to name your C and M print handler initialization
functions according to the rules presented below. Otherwise, the
correspondence between the two is missing.
Vue de la page 164
1 2 ... 160 161 162 163 164 165 166 167 168 169 170 ... 263 264

Commentaires sur ces manuels

Pas de commentaire