MATLAB R2010a is developed by The MathWorks, Inc. and is used by 279 users of Software Informer. The most popular version of this product among our users is 7.1. The names of program executable files are matlab.exe, deactivate_matlab.exe, $RHXG259.exe and activate_matlab.exe. The product will soon be reviewed by our informers.
and then I used matlab compiler to compile this function using matlab GUI compiler (File-> new -> Deployment Project and then choose C++ shared Library). It produces this files 2 folders: distrib and src.
I want to use this file in a C++ application. I tried many times and I didn't find a way. All the ways I found over the internet are using old matlab compiler which produces different files or works on an old version of visual studio.
If you put the foo.h file in the same directory as your source files, you won't need to do anything special to #include "foo.h". You can also add the direct path to foo.lib in the external linker dependencies.
Edit: You probably also need to add the MATLAB libraries to your include and library paths. Check out the MathWorks support solution Why do I receive the error 'Could not find include file "mclmcrrt.h"' when trying to compile a stand-alone application?
This step-by-step tutorial will show you how to set up a Netbeans Project to develop ImageJ plugins, which are using MATLAB code (wrapped with MATLAB Builder JE).
In this tutorial I'm not going to describe how to write a plugin, but if you succeed and develope one, then in the end you will have a plugin, that will be able to use ImageJ functions, other ImageJ plugins, external jar files, and jar files which call MATLAB functions without having MATLAB installed. You will only need MCR (described below), which is completely free.
Follow this guide:
This will show you how to create Netbeans project, how to update to the latest ImageJ source code, and how your build.xml should look like. You will have to compile your plugins every time you make some changes, but this is the best method I found to separate plugin compiling and source code compiling.
Now you have set the environment to successfully develop a ImageJ plugin which uses MATLAB user created .jar files.
Make sure you don't use namespaces in plugins, because otherwise you can't reach those MATLAB wrapper classes (or it will be difficult).
To call your wrapped MATLAB function you have to instantiate the wrapper class. In Netbeans you can browse your jar files, and see their structure and all of the wrapped classes. With Netbeans works 'intellisense', so you can browse your MATLAB functions after typing the class instance and putting a dot.
I highly recommend to write your plugin separated from those code segments where you use MATLAB types and reach MATLAB functions (make helper classes):
- MyPlugin_.java (main plugin class)
- MatlabDriver.java (reach matlab functions)
These class files should be in the plugins folder too.
Error: After you build your project, start Imagej and start your plugin you may notice crashes while calling MATLAB functions (in your plugin).
Solution: Clean your java install completly (java jre ans jdk), and install the latest jdk. If you have more jdk or jre versions installed they may interfere.
As described in Using Java Libraries,every installation of MATLAB includes a JVM allowing use of the Java API andthird-party Java libraries. All the helper functions included in the MATLABtoolbox make use of the Bio-Formats Java API. Please refer to theJavadocs for more information.
The default JVM settings in MATLAB can result injava.lang.OutOfMemoryError: Java heap space exceptions when opening largeimage files using Bio-Formats. Information about the Java heap space usage inMATLAB can be retrieved using:
However, the maximum value allowed in the Preferences GUI (typically set to 25% of Physical Memory, whihc you can ask by the memory MATLAB command) can still be too smallfor your purpose. In that case, you can directly edit matlab.prf file in thefolder specified by the prefdir MATLAB function(eg. 'C:\Users\xxxxxxx\AppData\Roaming\MathWorks\MATLAB\R2018b'). Find theparameter JavaMemHeapMax in the file and increase the number that followsthe capital I (in MB) to increase the maximum Java heap memory size. Thechange will be reflected by the Preferences as above.
Alternatively, this can also be done by creating a java.opts file inthe startup directoryand overriding the default memory settings (see this pagefor more information). We recommend using -Xmx512m (meaning 512 MB) in your java.optsfile.Calling:
If errors of type java.lang.OutOfMemoryError: PermGen space are thrownwhile using Bio-Formats with the Java bundled with MATLAB, youmay try to increase the default values of -XX:MaxPermSize and-XX:PermSize via the java.opts file.
This will display the first image of the first series with its associatedcolor map (if present). If you would prefer not to apply the color mapsassociated with each image, simply comment out the calls to colormap.
By default, bfsave will create a minimal OME-XML metadata objectcontaining basic information such as the pixel dimensions, the dimension orderand the pixel type.To customize the OME metadata, it is possible to create a metadata objectfrom the input array using createMinimalOMEXMLMetadata.m, add custommetadata and pass this object directly to bfsave:
Initializing a Bio-Formats reader can consume substantial time and memory.Most of the initialization time is spend in thesetId(java.lang.String)call. Various factors can impact the performance of this step including thefile size, the amount of metadata in the image and also the file format itself.
One solution to improve reading performance is to use Bio-Formats memoizationfunctionalities with theloci.formats.Memoizer reader wrapper.By essence, the speedup gained from memoization will only happen after thefirst initialization of the reader for a particular file.
If the time required to call setId(java.lang.String) method is largerthan DEFAULT_MINIMUM_ELAPSED or the minimum valuepassed in the constructor, the initialized reader will be cached in a memofile under the same folder as the input file. Any subsequent call tosetId() with a reader decorated by the Memoizer on the same input filewill load the reader from the memo file instead of performing a full readerinitialization.
More constructors are described in theMemoizer javadocs allowing to controlthe minimal initialization time required before caching the reader and/or todefine a root directory under which the reader should be cached.
As Bio-Formats is not thread-safe, reader memoization offers a new solution toincrease reading performance when doing parallel work. For instance, thefollowing example shows how to combine memoization and MATLAB parfor to dowork on a single file in a parallel loop:
b1e95dc632