-
-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Matlab API for other languages #96
Comments
While this is indeed an extremely neat feature of MATLAB, I think this is far out of the scope of this lesson. The audience for most SWC workshops have no real prior experience in programming, let alone in a low-level language such as C. |
Hi shwina, I agree that his is perhaps a more advanced feature of Matlab, but to my experience particularly for postgraduate students that need to process large data-sets this can be extremely beneficial. The c part of the code here is a bit complex it can be as simple as passing an argument and printing that to screen. The idea here is to make them aware of the this possibility and show them the mechanics of doing this, so that if they needed they can learn on their own. |
I do agree that if you are teaching an audience that (1) will have an immediate need for writing or modifying MEX-files, and (2) has prior experience with programming in C, it may be worth introducing the idea. For such a workshop, I would suggest making a copy of the lesson materials and adding the relevant contents. I don't believe that this will fit in with the core lesson though, which is intended really to teach general programming concepts, and not to introduce features very specific to MATLAB. |
I second this. In all my years working with MATLAB users, I hardly encounter anyone using MEX probably because they didn't have performance issues that make cost efficient to migrate their code to C/C++ and use MEX. Some friends used CUTEst: a Constrained and Unconstrained Testing Environment with safe threads for mathematical optimization and its MEX integration but had to handle the extra complexity of having a C/C++ compiler on their Windows machine. Said that, I think that worth mention MEX at the end of the workshop for things that people could look. As a novice, you don't know the words you need to search for. But you should not teach MEX at a novice Software Carpentry workshop. Python and R lessons don't teach their C/C++ integration. If you think your audience need to know MEX, it is the case to organise a workshop only to cover MEX. |
Thanks for your suggestion, but this is firmly out of scope for this lesson. |
A less known capability of matlab is c/c++ and fortran interoperability with mex functions to interface other languages. This can be added as a part of the course and I found this an extremely powerful tool, this can be a short introduction with a simple example as follow:
Following is a demonstration of how this would work,
Assuming the mex command is configured correctly (following documentation, you need a c or fortran compiler and need to use mex -setup); do the following
the required c file (copy and paste in dist.c, this calculates a distance but the for loop can be simplified to something like just squaring elements or something similar), this can be provided for the students.
The text was updated successfully, but these errors were encountered: