SlideShare una empresa de Scribd logo
1 de 16
Integrating C, C++ with MATLAB
Why integrate C/C++ with MATLAB? Speed: C, C++ code can provide really fast computation compared to MATLAB. Data structure management can be a difficult task in C,C++ but very easy in MATLAB.
Why integrate C/C++ with MATLAB? Data Structure Management Speed
Integrating C++ with MATLAB For integration of C/C++ with MATLAB, we make use of MEX files MEX files are pre-compiled files that are called from MATLAB MEX files can be compiled from Matlab.m files MEX files can also be compiled from external C/C++ code.
MEX files
Components of a MEX file Every MEX file consists of two parts: A gateway routine that interacts with Matlab procedures. Must be called ‘mexFunction()’. This is the point for the C++ code to enter.  Subroutine Section which contains any number of subroutines that are called from the gateway routine.  Most portion of our computation will be inside these subroutines.
Writing MEX files It is always assumed when writing C programs that the program will start execution from the main(). On the contrary, MEX -Files always start execution from a special function called the mexFunction(). This function has return type void and is the "gateway" between the MATLAB function call, and our C code.
Writing MEX files In order to make a mex-function, you must include the "mex.h" library. #include "math.h"  #include   "mex.h"
Writing MEX files There are four input parameters to the mexFunction: nlhs (Type = int) plhs (Type = array of pointers to mxArrays) nrhs (Type = int) prhs (Type = const array of pointers to mxArrays)
Writing MEX files nlhs  represents the number of "left hand side" arguments. plhs  is the actual output arguments. An mxArray is MATLAB's structure for holding data and each element in plhs holds an mxArray of data. nrhs  holds the number of "right hand side" arguments. prhs  holds all of the pointers to the mxArrays of input data
Writing MEX files mxArrayis the main MATLAB structure used for holding data in MEX-Files is the. This structure can hold real data, complex data, arrays, matrices, sparse-arrays, strings, and a whole host of other MATLAB data-structures.
Calling Built-In Functions from a MEX-File MATLAB has provided the capability of calling pre-written functions in MATLAB. Built-In functions of MATLAB have a parameter list similar to the mexFunction() itself.
Calling Built-In Functions from a MEX-File Example: mxArray *result; mxArray *arguments[2]; arguments[0] = mxCreateDoubleMatrix(1, 20, mxREAL); arguments[1] = mxCreateDoubleMatrix(1, 10, mxREAL); mexCallMATLAB(1,&result,2,arguments,"conv");
Compiling a MEX file In the MATLAB command prompt:, Change the current directory to the location of the MEX source file.  Type: mexfilename.c into the MATLAB command window. MATLAB may ask you to choose a compiler. Choose the compiler with MATLAB in its directory path.  The new function will be called with the same name as our file.
Using the MEX binary After successful compilation of the MEX source file, MATLAB produces the actual MEX binary that can be called as a normal MATLAB function. To call this function, we must be in the same directory as the binary. 
Using the MEX binary On different systems, the MEX binary goes by different extensions: Windows=.dll MacOSX=.mexmac Solaris=.mexsol Linux=.mexlx

Más contenido relacionado

La actualidad más candente

10 Linked Lists Sacks and Queues
10 Linked Lists Sacks and Queues10 Linked Lists Sacks and Queues
10 Linked Lists Sacks and QueuesPraveen M Jigajinni
 
Ppt on Linked list,stack,queue
Ppt on Linked list,stack,queuePpt on Linked list,stack,queue
Ppt on Linked list,stack,queueSrajan Shukla
 
Stacks & Queues By Ms. Niti Arora
Stacks & Queues By Ms. Niti AroraStacks & Queues By Ms. Niti Arora
Stacks & Queues By Ms. Niti Arorakulachihansraj
 
Doubly & Circular Linked Lists
Doubly & Circular Linked ListsDoubly & Circular Linked Lists
Doubly & Circular Linked ListsAfaq Mansoor Khan
 
Doubly linked list
Doubly linked listDoubly linked list
Doubly linked listFahd Allebdi
 
Linked List Static and Dynamic Memory Allocation
Linked List Static and Dynamic Memory AllocationLinked List Static and Dynamic Memory Allocation
Linked List Static and Dynamic Memory AllocationProf Ansari
 
358 33 powerpoint-slides_8-linked-lists_chapter-8
358 33 powerpoint-slides_8-linked-lists_chapter-8358 33 powerpoint-slides_8-linked-lists_chapter-8
358 33 powerpoint-slides_8-linked-lists_chapter-8sumitbardhan
 
Operations on linked list
Operations on linked listOperations on linked list
Operations on linked listSumathi Kv
 
Circular linked list
Circular linked listCircular linked list
Circular linked listdchuynh
 
Circular link list.ppt
Circular link list.pptCircular link list.ppt
Circular link list.pptTirthika Bandi
 

La actualidad más candente (18)

Singly link list
Singly link listSingly link list
Singly link list
 
linked list
linked list linked list
linked list
 
10 Linked Lists Sacks and Queues
10 Linked Lists Sacks and Queues10 Linked Lists Sacks and Queues
10 Linked Lists Sacks and Queues
 
Ppt on Linked list,stack,queue
Ppt on Linked list,stack,queuePpt on Linked list,stack,queue
Ppt on Linked list,stack,queue
 
single linked list
single linked listsingle linked list
single linked list
 
Stacks & Queues By Ms. Niti Arora
Stacks & Queues By Ms. Niti AroraStacks & Queues By Ms. Niti Arora
Stacks & Queues By Ms. Niti Arora
 
Doubly & Circular Linked Lists
Doubly & Circular Linked ListsDoubly & Circular Linked Lists
Doubly & Circular Linked Lists
 
Doubly linked list
Doubly linked listDoubly linked list
Doubly linked list
 
Linked List Static and Dynamic Memory Allocation
Linked List Static and Dynamic Memory AllocationLinked List Static and Dynamic Memory Allocation
Linked List Static and Dynamic Memory Allocation
 
Doubly Link List
Doubly Link ListDoubly Link List
Doubly Link List
 
Ch13
Ch13Ch13
Ch13
 
linked list
linked list linked list
linked list
 
Link List
Link ListLink List
Link List
 
358 33 powerpoint-slides_8-linked-lists_chapter-8
358 33 powerpoint-slides_8-linked-lists_chapter-8358 33 powerpoint-slides_8-linked-lists_chapter-8
358 33 powerpoint-slides_8-linked-lists_chapter-8
 
Operations on linked list
Operations on linked listOperations on linked list
Operations on linked list
 
Bitstuffing
BitstuffingBitstuffing
Bitstuffing
 
Circular linked list
Circular linked listCircular linked list
Circular linked list
 
Circular link list.ppt
Circular link list.pptCircular link list.ppt
Circular link list.ppt
 

Destacado

Matlab Image Restoration Techniques
Matlab Image Restoration TechniquesMatlab Image Restoration Techniques
Matlab Image Restoration Techniquesmatlab Content
 
Image Restoration (Digital Image Processing)
Image Restoration (Digital Image Processing)Image Restoration (Digital Image Processing)
Image Restoration (Digital Image Processing)Kalyan Acharjya
 
basic of Image processing using matlab
basic of Image processing using matlabbasic of Image processing using matlab
basic of Image processing using matlabRohit Sinha
 
Basics of Image Processing using MATLAB
Basics of Image Processing using MATLABBasics of Image Processing using MATLAB
Basics of Image Processing using MATLABE2MATRIX
 
Introduction to matlab_application_to_electrical_engineering
Introduction to matlab_application_to_electrical_engineeringIntroduction to matlab_application_to_electrical_engineering
Introduction to matlab_application_to_electrical_engineeringzulfikar37
 
Simulink - Introduction with Practical Example
Simulink - Introduction with Practical ExampleSimulink - Introduction with Practical Example
Simulink - Introduction with Practical ExampleKamran Gillani
 
Modelling and Simulation of DC-Motor Electric Drive Control System with Varia...
Modelling and Simulation of DC-Motor Electric Drive Control System with Varia...Modelling and Simulation of DC-Motor Electric Drive Control System with Varia...
Modelling and Simulation of DC-Motor Electric Drive Control System with Varia...IDES Editor
 
Image degradation and noise by Md.Naseem Ashraf
Image degradation and noise by Md.Naseem AshrafImage degradation and noise by Md.Naseem Ashraf
Image degradation and noise by Md.Naseem AshrafMD Naseem Ashraf
 
IEEE electrical projects using Matlab/Simulink software
IEEE electrical projects using Matlab/Simulink softwareIEEE electrical projects using Matlab/Simulink software
IEEE electrical projects using Matlab/Simulink softwareAsoka Technologies
 
Matlab dc motor modeling
Matlab dc motor modelingMatlab dc motor modeling
Matlab dc motor modelingAmeen San
 
How to Design of Power Management of Hybrid Circuit(Li-Ion Battery and Li-Ion...
How to Design of Power Management of Hybrid Circuit(Li-Ion Battery and Li-Ion...How to Design of Power Management of Hybrid Circuit(Li-Ion Battery and Li-Ion...
How to Design of Power Management of Hybrid Circuit(Li-Ion Battery and Li-Ion...Tsuyoshi Horigome
 
Speed control of dc motor using matlab
Speed control of dc motor using matlabSpeed control of dc motor using matlab
Speed control of dc motor using matlabShridhar kulkarni
 
Digital Image Processing - Image Restoration
Digital Image Processing - Image RestorationDigital Image Processing - Image Restoration
Digital Image Processing - Image RestorationMathankumar S
 
Matlab for Electrical Engineers
Matlab for Electrical EngineersMatlab for Electrical Engineers
Matlab for Electrical EngineersManish Joshi
 
MINI ELECTRICAL PROJECT
MINI ELECTRICAL PROJECTMINI ELECTRICAL PROJECT
MINI ELECTRICAL PROJECTananthavignesh
 
filters for noise in image processing
filters for noise in image processingfilters for noise in image processing
filters for noise in image processingSardar Alam
 
Micro-controller based Automatic Power Factor Correction System Report
Micro-controller based Automatic Power Factor Correction System ReportMicro-controller based Automatic Power Factor Correction System Report
Micro-controller based Automatic Power Factor Correction System ReportTheory to Practical
 

Destacado (20)

Matlab Image Restoration Techniques
Matlab Image Restoration TechniquesMatlab Image Restoration Techniques
Matlab Image Restoration Techniques
 
Image Restoration (Digital Image Processing)
Image Restoration (Digital Image Processing)Image Restoration (Digital Image Processing)
Image Restoration (Digital Image Processing)
 
Mex help
Mex helpMex help
Mex help
 
basic of Image processing using matlab
basic of Image processing using matlabbasic of Image processing using matlab
basic of Image processing using matlab
 
Image processing
Image processingImage processing
Image processing
 
Basics of Image Processing using MATLAB
Basics of Image Processing using MATLABBasics of Image Processing using MATLAB
Basics of Image Processing using MATLAB
 
Introduction to matlab_application_to_electrical_engineering
Introduction to matlab_application_to_electrical_engineeringIntroduction to matlab_application_to_electrical_engineering
Introduction to matlab_application_to_electrical_engineering
 
Simulink - Introduction with Practical Example
Simulink - Introduction with Practical ExampleSimulink - Introduction with Practical Example
Simulink - Introduction with Practical Example
 
Modelling and Simulation of DC-Motor Electric Drive Control System with Varia...
Modelling and Simulation of DC-Motor Electric Drive Control System with Varia...Modelling and Simulation of DC-Motor Electric Drive Control System with Varia...
Modelling and Simulation of DC-Motor Electric Drive Control System with Varia...
 
Image degradation and noise by Md.Naseem Ashraf
Image degradation and noise by Md.Naseem AshrafImage degradation and noise by Md.Naseem Ashraf
Image degradation and noise by Md.Naseem Ashraf
 
IEEE electrical projects using Matlab/Simulink software
IEEE electrical projects using Matlab/Simulink softwareIEEE electrical projects using Matlab/Simulink software
IEEE electrical projects using Matlab/Simulink software
 
Matlab dc motor modeling
Matlab dc motor modelingMatlab dc motor modeling
Matlab dc motor modeling
 
How to Design of Power Management of Hybrid Circuit(Li-Ion Battery and Li-Ion...
How to Design of Power Management of Hybrid Circuit(Li-Ion Battery and Li-Ion...How to Design of Power Management of Hybrid Circuit(Li-Ion Battery and Li-Ion...
How to Design of Power Management of Hybrid Circuit(Li-Ion Battery and Li-Ion...
 
Speed control of dc motor using matlab
Speed control of dc motor using matlabSpeed control of dc motor using matlab
Speed control of dc motor using matlab
 
Digital Image Processing - Image Restoration
Digital Image Processing - Image RestorationDigital Image Processing - Image Restoration
Digital Image Processing - Image Restoration
 
Matlab for Electrical Engineers
Matlab for Electrical EngineersMatlab for Electrical Engineers
Matlab for Electrical Engineers
 
MINI ELECTRICAL PROJECT
MINI ELECTRICAL PROJECTMINI ELECTRICAL PROJECT
MINI ELECTRICAL PROJECT
 
Noise Models
Noise ModelsNoise Models
Noise Models
 
filters for noise in image processing
filters for noise in image processingfilters for noise in image processing
filters for noise in image processing
 
Micro-controller based Automatic Power Factor Correction System Report
Micro-controller based Automatic Power Factor Correction System ReportMicro-controller based Automatic Power Factor Correction System Report
Micro-controller based Automatic Power Factor Correction System Report
 

Similar a C,C++ In Matlab

Similar a C,C++ In Matlab (20)

Matlab Manual
Matlab ManualMatlab Manual
Matlab Manual
 
Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlab
 
Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlab
 
Matlab guide
Matlab guideMatlab guide
Matlab guide
 
Introduction to MATLAB
Introduction to MATLABIntroduction to MATLAB
Introduction to MATLAB
 
Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlab
 
Mex help hay vai
Mex help hay vaiMex help hay vai
Mex help hay vai
 
An ntutorial[1]
An ntutorial[1]An ntutorial[1]
An ntutorial[1]
 
Dsp file
Dsp fileDsp file
Dsp file
 
Matlab summary
Matlab summaryMatlab summary
Matlab summary
 
Brief Introduction to Matlab
Brief  Introduction to MatlabBrief  Introduction to Matlab
Brief Introduction to Matlab
 
interfacing matlab with embedded systems
interfacing matlab with embedded systemsinterfacing matlab with embedded systems
interfacing matlab with embedded systems
 
Matlab basic and image
Matlab basic and imageMatlab basic and image
Matlab basic and image
 
From zero to MATLAB hero: Mastering the basics and beyond
From zero to MATLAB hero: Mastering the basics and beyondFrom zero to MATLAB hero: Mastering the basics and beyond
From zero to MATLAB hero: Mastering the basics and beyond
 
Matlab Introduction
Matlab IntroductionMatlab Introduction
Matlab Introduction
 
Kevin merchantss
Kevin merchantssKevin merchantss
Kevin merchantss
 
KEVIN MERCHANT DOCUMENT
KEVIN MERCHANT DOCUMENTKEVIN MERCHANT DOCUMENT
KEVIN MERCHANT DOCUMENT
 
MATLAB INTRODUCTION
MATLAB INTRODUCTIONMATLAB INTRODUCTION
MATLAB INTRODUCTION
 
Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlab
 
Introduction to matlab lecture 1 of 4
Introduction to matlab lecture 1 of 4Introduction to matlab lecture 1 of 4
Introduction to matlab lecture 1 of 4
 

Más de matlab Content

Matlab: Control Statements
Matlab: Control StatementsMatlab: Control Statements
Matlab: Control Statementsmatlab Content
 
Matlab: Discrete Linear Systems
Matlab: Discrete Linear SystemsMatlab: Discrete Linear Systems
Matlab: Discrete Linear Systemsmatlab Content
 
Matlab: Linear Methods, Quantiles
Matlab: Linear Methods, QuantilesMatlab: Linear Methods, Quantiles
Matlab: Linear Methods, Quantilesmatlab Content
 
Matlab Data And Statistics
Matlab Data And StatisticsMatlab Data And Statistics
Matlab Data And Statisticsmatlab Content
 
Matlab Feature Extraction Using Segmentation And Edge Detection
Matlab Feature Extraction Using Segmentation And Edge DetectionMatlab Feature Extraction Using Segmentation And Edge Detection
Matlab Feature Extraction Using Segmentation And Edge Detectionmatlab Content
 
Matlab Image Enhancement Techniques
Matlab Image Enhancement TechniquesMatlab Image Enhancement Techniques
Matlab Image Enhancement Techniquesmatlab Content
 
Matlab Organizing Data
Matlab Organizing DataMatlab Organizing Data
Matlab Organizing Datamatlab Content
 
Matlab Visualizing Data
Matlab Visualizing DataMatlab Visualizing Data
Matlab Visualizing Datamatlab Content
 
Matlab Working With Images
Matlab Working With ImagesMatlab Working With Images
Matlab Working With Imagesmatlab Content
 
Matlab: Non Linear Methods
Matlab: Non Linear MethodsMatlab: Non Linear Methods
Matlab: Non Linear Methodsmatlab Content
 
Matlab: Procedures And Functions
Matlab: Procedures And FunctionsMatlab: Procedures And Functions
Matlab: Procedures And Functionsmatlab Content
 
Matlab: Programming Environment
Matlab: Programming EnvironmentMatlab: Programming Environment
Matlab: Programming Environmentmatlab Content
 
Matlab: Saving And Publishing
Matlab: Saving And PublishingMatlab: Saving And Publishing
Matlab: Saving And Publishingmatlab Content
 
Matlab: Spectral Analysis, Fourier Analysis, Filterbank Analysis
Matlab: Spectral Analysis, Fourier Analysis, Filterbank AnalysisMatlab: Spectral Analysis, Fourier Analysis, Filterbank Analysis
Matlab: Spectral Analysis, Fourier Analysis, Filterbank Analysismatlab Content
 

Más de matlab Content (20)

Matlab: Control Statements
Matlab: Control StatementsMatlab: Control Statements
Matlab: Control Statements
 
Matlab: Discrete Linear Systems
Matlab: Discrete Linear SystemsMatlab: Discrete Linear Systems
Matlab: Discrete Linear Systems
 
Matlab Distributions
Matlab DistributionsMatlab Distributions
Matlab Distributions
 
Matlab: Graph Plots
Matlab: Graph PlotsMatlab: Graph Plots
Matlab: Graph Plots
 
Matlab: Gui
Matlab: GuiMatlab: Gui
Matlab: Gui
 
Matlab: Linear Methods, Quantiles
Matlab: Linear Methods, QuantilesMatlab: Linear Methods, Quantiles
Matlab: Linear Methods, Quantiles
 
Matlab Data And Statistics
Matlab Data And StatisticsMatlab Data And Statistics
Matlab Data And Statistics
 
Matlab Feature Extraction Using Segmentation And Edge Detection
Matlab Feature Extraction Using Segmentation And Edge DetectionMatlab Feature Extraction Using Segmentation And Edge Detection
Matlab Feature Extraction Using Segmentation And Edge Detection
 
Matlab Image Enhancement Techniques
Matlab Image Enhancement TechniquesMatlab Image Enhancement Techniques
Matlab Image Enhancement Techniques
 
Matlab Importing Data
Matlab Importing DataMatlab Importing Data
Matlab Importing Data
 
Matlab Organizing Data
Matlab Organizing DataMatlab Organizing Data
Matlab Organizing Data
 
Matlab Text Files
Matlab Text FilesMatlab Text Files
Matlab Text Files
 
Matlab Visualizing Data
Matlab Visualizing DataMatlab Visualizing Data
Matlab Visualizing Data
 
Matlab Working With Images
Matlab Working With ImagesMatlab Working With Images
Matlab Working With Images
 
Matlab: Non Linear Methods
Matlab: Non Linear MethodsMatlab: Non Linear Methods
Matlab: Non Linear Methods
 
Matlab: Procedures And Functions
Matlab: Procedures And FunctionsMatlab: Procedures And Functions
Matlab: Procedures And Functions
 
Matlab: Programming Environment
Matlab: Programming EnvironmentMatlab: Programming Environment
Matlab: Programming Environment
 
Matlab: Regression
Matlab: RegressionMatlab: Regression
Matlab: Regression
 
Matlab: Saving And Publishing
Matlab: Saving And PublishingMatlab: Saving And Publishing
Matlab: Saving And Publishing
 
Matlab: Spectral Analysis, Fourier Analysis, Filterbank Analysis
Matlab: Spectral Analysis, Fourier Analysis, Filterbank AnalysisMatlab: Spectral Analysis, Fourier Analysis, Filterbank Analysis
Matlab: Spectral Analysis, Fourier Analysis, Filterbank Analysis
 

Último

Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...itnewsafrica
 
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...Karmanjay Verma
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesBernd Ruecker
 
Kuma Meshes Part I - The basics - A tutorial
Kuma Meshes Part I - The basics - A tutorialKuma Meshes Part I - The basics - A tutorial
Kuma Meshes Part I - The basics - A tutorialJoão Esperancinha
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)Mark Simos
 
Digital Tools & AI in Career Development
Digital Tools & AI in Career DevelopmentDigital Tools & AI in Career Development
Digital Tools & AI in Career DevelopmentMahmoud Rabie
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Kaya Weers
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesKari Kakkonen
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 
All These Sophisticated Attacks, Can We Really Detect Them - PDF
All These Sophisticated Attacks, Can We Really Detect Them - PDFAll These Sophisticated Attacks, Can We Really Detect Them - PDF
All These Sophisticated Attacks, Can We Really Detect Them - PDFMichael Gough
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesManik S Magar
 
Accelerating Enterprise Software Engineering with Platformless
Accelerating Enterprise Software Engineering with PlatformlessAccelerating Enterprise Software Engineering with Platformless
Accelerating Enterprise Software Engineering with PlatformlessWSO2
 
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...amber724300
 
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...itnewsafrica
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesThousandEyes
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...panagenda
 

Último (20)

Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
 
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architectures
 
Kuma Meshes Part I - The basics - A tutorial
Kuma Meshes Part I - The basics - A tutorialKuma Meshes Part I - The basics - A tutorial
Kuma Meshes Part I - The basics - A tutorial
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
 
Digital Tools & AI in Career Development
Digital Tools & AI in Career DevelopmentDigital Tools & AI in Career Development
Digital Tools & AI in Career Development
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 
All These Sophisticated Attacks, Can We Really Detect Them - PDF
All These Sophisticated Attacks, Can We Really Detect Them - PDFAll These Sophisticated Attacks, Can We Really Detect Them - PDF
All These Sophisticated Attacks, Can We Really Detect Them - PDF
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
 
Accelerating Enterprise Software Engineering with Platformless
Accelerating Enterprise Software Engineering with PlatformlessAccelerating Enterprise Software Engineering with Platformless
Accelerating Enterprise Software Engineering with Platformless
 
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
 
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
 

C,C++ In Matlab

  • 1. Integrating C, C++ with MATLAB
  • 2. Why integrate C/C++ with MATLAB? Speed: C, C++ code can provide really fast computation compared to MATLAB. Data structure management can be a difficult task in C,C++ but very easy in MATLAB.
  • 3. Why integrate C/C++ with MATLAB? Data Structure Management Speed
  • 4. Integrating C++ with MATLAB For integration of C/C++ with MATLAB, we make use of MEX files MEX files are pre-compiled files that are called from MATLAB MEX files can be compiled from Matlab.m files MEX files can also be compiled from external C/C++ code.
  • 6. Components of a MEX file Every MEX file consists of two parts: A gateway routine that interacts with Matlab procedures. Must be called ‘mexFunction()’. This is the point for the C++ code to enter. Subroutine Section which contains any number of subroutines that are called from the gateway routine. Most portion of our computation will be inside these subroutines.
  • 7. Writing MEX files It is always assumed when writing C programs that the program will start execution from the main(). On the contrary, MEX -Files always start execution from a special function called the mexFunction(). This function has return type void and is the "gateway" between the MATLAB function call, and our C code.
  • 8. Writing MEX files In order to make a mex-function, you must include the "mex.h" library. #include "math.h" #include "mex.h"
  • 9. Writing MEX files There are four input parameters to the mexFunction: nlhs (Type = int) plhs (Type = array of pointers to mxArrays) nrhs (Type = int) prhs (Type = const array of pointers to mxArrays)
  • 10. Writing MEX files nlhs  represents the number of "left hand side" arguments. plhs  is the actual output arguments. An mxArray is MATLAB's structure for holding data and each element in plhs holds an mxArray of data. nrhs  holds the number of "right hand side" arguments. prhs  holds all of the pointers to the mxArrays of input data
  • 11. Writing MEX files mxArrayis the main MATLAB structure used for holding data in MEX-Files is the. This structure can hold real data, complex data, arrays, matrices, sparse-arrays, strings, and a whole host of other MATLAB data-structures.
  • 12. Calling Built-In Functions from a MEX-File MATLAB has provided the capability of calling pre-written functions in MATLAB. Built-In functions of MATLAB have a parameter list similar to the mexFunction() itself.
  • 13. Calling Built-In Functions from a MEX-File Example: mxArray *result; mxArray *arguments[2]; arguments[0] = mxCreateDoubleMatrix(1, 20, mxREAL); arguments[1] = mxCreateDoubleMatrix(1, 10, mxREAL); mexCallMATLAB(1,&result,2,arguments,"conv");
  • 14. Compiling a MEX file In the MATLAB command prompt:, Change the current directory to the location of the MEX source file. Type: mexfilename.c into the MATLAB command window. MATLAB may ask you to choose a compiler. Choose the compiler with MATLAB in its directory path. The new function will be called with the same name as our file.
  • 15. Using the MEX binary After successful compilation of the MEX source file, MATLAB produces the actual MEX binary that can be called as a normal MATLAB function. To call this function, we must be in the same directory as the binary. 
  • 16. Using the MEX binary On different systems, the MEX binary goes by different extensions: Windows=.dll MacOSX=.mexmac Solaris=.mexsol Linux=.mexlx