MATLAB APPLICATION DEPLOYMENT - WEB EXAMPLE GUIDE Betriebsanweisung Seite 93

  • Herunterladen
  • Zu meinen Handbüchern hinzufügen
  • Drucken
  • Seite
    / 354
  • Inhaltsverzeichnis
  • FEHLERBEHEBUNG
  • LESEZEICHEN
  • Bewertet. / 5. Basierend auf Kundenbewertungen
Seitenansicht 92
Interfacing M-Co de to C/C++ Code
Inter facing M -Code to C/C++ Code
In this section...
“Overview” on page 5-13
“C Ex ample” on page 5-13
Overview
MATLAB Compiler supports calling arbitrary C/C++ functions from your
M-code. You simply provide an M-function stub that determines how the code
will be have in M, and then provide an implementation of the body of the
function in C or C++.
CExample
Suppose you have a C function that reads data from a measurement
device. In M-code, you want to simulate the device by providing a sine
wave output. In production, you want to provide a function that returns
the meas urement obtained from the device. You have a C function called
measure_from_device() that returns a double, which is the current
measurement.
collect.m containstheM-codeforthesimulation of your application.
function collect
y = zeros(1, 100); %Preallocate the matrix
for i = 1:100
y(i) = collect_one;
end
disp (y)
function y = collect_one
persistent t;
if (isempty(t))
t=0;
end
5-13
Seitenansicht 92
1 2 ... 88 89 90 91 92 93 94 95 96 97 98 ... 353 354

Kommentare zu diesen Handbüchern

Keine Kommentare