Matlab c\c++ function Library is an important part of the extension function of Matlab, contains a lot of MATLAB functions rewritten with c\c++ language, including elementary mathematics function, linear algebra function, matrix operation function, numerical calculation function, special mathematical function, polynomial function, Interpolation functions, users can call these functions in their own c\c++ programs to achieve complex matrix computing functions, thereby reducing the workload of programming, it needs to be explained that C function library and C + + function library is two different function libraries.
Installation is required before use:
In the MATLAB command window, enter:
Mbuild-setup
Follow the prompts to select the VC compiler, completed in the MATLAB command Window input:
Mex-setup
Also select the VC compiler, the compiler to complete the installation and configuration.
Firstly, we introduce the library functions of C function library and C functions library under this directory: Matlab root directory: \extern\lib
Here is a matlab with a use of C function library example (all using the C function example in: Matlab root directory \extern\examples\cmath):* EX1.C
*
* Copyright (c) 1995-1999 by the MathWorks, Inc. All Rights Reserved.
*/
/* $Revision: 1.6 $/*
#include <stdio.h>
#include <stdlib.h>/* Used for exit_success * *
#include <string.h>
#include "Matlab.h"/*matlab.h as the header file for the C Math function library
Static double real_data[] = {1, 2, 3, 4, 5, 6};
Static double cplx_data[] = {7, 8, 9, 10, 11, 12};
int main ()
{
/* Declare two Mxarray matrix variable and assign initial value to NULL * *
Mxarray *mat0 = NULL;
Mxarray *MAT1 = NULL;
/* Use automatic memory management * *
Mlfenternewcontext (0, 0);
/* Create matrix MAT0,MAT1 and assign value * *
Mlfassign (&mat0, Mlfdoublematrix (2, 3, Real_data, NULL));/* This matrix is a 2*3 matrix
Mlfassign (&MAT1, Mlfdoublematrix (3, 2, Real_data, Cplx_data));/* The Matrix is a 2*3 matrix and is a complex matrix
/* Print Matrix * *
Mlfprintmatrix (MAT0);
Mlfprintmatrix (MAT1);
/* Release the memory of the matrix * *
Mxdestroyarray (MAT0);
Mxdestroyarray (MAT1);
/* Disable automatic memory management * *
Mlfrestorepreviouscontext (0, 0);
return (exit_success);
}
If there is an image, please indicate the image index number in the image file, such as "Myappimg1.gif", "myappimg2.gif", and so on, in the image display below annotated image description:
Figure A program running results