MATLAB REAL-TIME WORKSHOP 7 - TARGET LANGUAGE COMPILER Manual de usuario Pagina 84

  • Descarga
  • Añadir a mis manuales
  • Imprimir
  • Pagina
    / 408
  • Tabla de contenidos
  • MARCADORES
  • Valorado. / 5. Basado en revisión del cliente
Vista de pagina 83
2 Creating C Language MEX-Files
2-24
arithmetic on data of 8-, 16- or 32-bit precision in MEX-files and return the
result to MATLAB, which will recognize the correct data class. Although from
within MATLAB it is not currently possible to perform arithmetic or to call
MATLAB functions that perform data manipulation on data of 8-, 16-, or 32-bit
precision, you can display the data at the MATLAB prompt and save it in a
MAT-file.
This example constructs a 2-by-2 matrix with unsigned 16-bit integers, doubles
each element, and returns both matrices to MATLAB.
#include <string.h> /* Needed for memcpy() */
#include "mex.h"
/*
* doubleelement.c - Example found in API Guide
*
* Constructs a 2-by-2 matrix with unsigned 16-bit integers,
* doubles each element, and returns the matrix.
*
* This is a MEX-file for MATLAB.
* Copyright (c) 1984-2000 The MathWorks, Inc.
*/
/* $Revision: 1.8 $ */
#define NDIMS 2
#define TOTAL_ELEMENTS 4
/* The computational subroutine */
void dbl_elem(unsigned short *x)
{
unsigned short scalar = 2;
int i,j;
for(i = 0; i < 2;i++) {
for(j = 0; j < 2;j++) {
*(x+i+j) = scalar * *(x+i+j);
}
}
}
Vista de pagina 83
1 2 ... 79 80 81 82 83 84 85 86 87 88 89 ... 407 408

Comentarios a estos manuales

Sin comentarios