Does ver only support toolbox? - matlab

The link here mentions that the following line is placed in the second line of the Contents.m file, calling ver will print it out as the version.
% Version 1.0.0.0 20-Dec-2016
Does this work only for toolboxes? I have a non-toolbox folder foo. If I do ver foo, it said it cannot find the correct format of version.

It works for any folder on the MATLAB path.
Create a folder called mytmpfolder, and put in it the following file Contents.m:
Contents.m
% MYTMPFOLDER
% Version 2.1.8 (My Version Name) 16-Dec-2016
%
% Description goes here.
%
% MYTMPFOLDER
% mytmpfolder - Some code for doing stuff.
Make sure mytmpfolder is on the MATLAB path. Then type:
>> help mytmpfolder
mytmpfolder
Version 2.1.8 (My Version Name) 16-Dec-2016
Description goes here.
mytmpfolder
mytmpfolder - Some code for doing stuff.
>> ver mytmpfolder
----------------------------------------------------------------------------------------------------
MATLAB Version: 9.0.0.341360 (R2016a)
MATLAB License Number: 628350
Operating System: Microsoft Windows 7 Enterprise Version 6.1 (Build 7601: Service Pack 1)
Java Version: Java 1.7.0_60-b19 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
----------------------------------------------------------------------------------------------------
MYTMPFOLDER Version 2.1.8 (My Version Name)
>> v = ver('mytmpfolder')
v =
Name: 'MYTMPFOLDER'
Version: '2.1.8'
Release: '(My Version Name)'
Date: '16-Dec-2016'
By the way, there's not really any such thing as a "toolbox folder" vs a "non-toolbox folder". Toolboxes are products from MathWorks, or products that other people make, but once they're installed they're really just folders full of code like any other folders full of code. You'd usually use a mechanism like Contents.m to indicate that a folder represented a sort of special point that collected together an important set of code, but it's up to you.

Related

Statet in eclipse does not find the rj package

I cannot get Eclipse, Statet, and R to work together. I receive an error when I launch R:
Launching the R Console was cancelled, because it seems starting the R engine failed.
Please make sure that R package 'rj' (2.0 or compatible) is installed and that the R library paths are set correctly for the R environment configuration 'R test'.
I have installed Eclipse Luna (64 bit), Statet, Java 1.8.0_25 (64bit) and R 3.1.2 (64bit). I am running on windows 7 (64bit). As required I installed the packages "rj" and "rj.gd" using:
install.packages(c("rj", "rj.gd"), repos="http://download.walware.de/rj-2.0")
It installed fine:
packageDescription("rj")
Encoding: UTF-8
Package: rj
Version: 2.0.2-1
Title: RJ - R Package for high-level Java-R library RJ
Author: Stephan Wahlbrink, Tobias Verbeke, low-level R binding based on the JRI library by Simon Urbanek
Maintainer: Stephan Wahlbrink <stephan.wahlbrink#walware.de>
Depends: R (>= 2.11.0)
Suggests: rj.gd
SystemRequirements: java
Description: Server implementation and R functions for the high-level Java-R library RJ. The package also includes callback functions for StatET. It is shipped with an adapted version of the JRI library. The package can be used only when R was loaded via RJ.
License: LGPL (>= 2.1)
URL: http://www.walware.de/goto/opensource
Packaged: 2014-07-11 15:43:15 UTC; build
Built: R 3.1.1; x86_64-w64-mingw32; 2014-07-11 15:47:59 UTC; windows
-- File: c:/~/R/win-library/3.1/rj/Meta/package.rds
I made sure that the library path is correct. I am a bit at a loss, how to proceed.
thanks for the help.
Christoph
Whilst digging around in the R-environment configuration (Run -> Run configurations... -> R config -> Configure), I tried something which worked:
Instead of specifying the user library link under "R_LIBS_USER", add an entry under "R_LIBS_SITE".
It works fine after that.
(I would have included visual pointers, but no rep)
I set R_LIBS_USER to the /library/ folder in the R environment and it worked fine.

Problems compiling CUDA with MEX in Matlab2014a

I am trying to compile a CUDA program using MEX within Matlab2014a and can't get it to work.
I installed the newest CUDA toolbox (6.5) and driver (340.62) and the samples work correctly, so I guess it is correctly installed.
I also installed MS Visual Studio 2012 Professional and Matlab 2014a.
I followed the exact description in the Matlab Help in "GPU Computing -> Examples and How To -> Run MEX-Functions Containing CUDA Code".
My CUDA file ends with .cu (so I am trying to compile Matlab's standard example mexGPUExample.cu, but I get the same error with other .cu files), the mex_CUDA_win64.xml is in the same folder, the environment variable MW_NVCC_PATH is set correctly in the user variables and just to be sure I also called "setenv('MW_NVCC_PATH,...)" in Matlab.
If I try to compile a CUDA example with
mex -largeArrayDims mexGPUExample.cu
I get the following error:
cl : Command line warning D9024 : unrecognized source file type 'mexGPUExample.cu', object file assumed
cl : Command line warning D9027 : source file 'mexGPUExample.cu' ignored
cl : Command line warning D9021 : no action performed
D:\PROGRAMS\MATLAB~1\BIN\MEX.PL: Error: Compile of 'mexGPUExample.cu' failed.
Unable to complete successfully.
I also tried to set the compiler correctly using
mex -setup
and chose the MS Visual Studio Compiler.
The code itself works because I tested it on other systems.
I have no idea what I am doing wrong.
Any help is appreciated.
Matlab only supports CUDA 5.5 on R2014a, so your CUDA 6.5 by default cannot compile mex files under Matlab. Matlab R2014a supports VS 2012 now, but you need to verify you have VS 64-bit compiler if your Matlab is 64-bit. You can compile a normal .mex file with .cpp source file, (lots of these files under matlabroot/extern folder) to see whether Matlab works well with your VS.
Note that Matlab has a lag in supporting the latest compilers, both VS/gcc and Cuda. It is always good choice to check the compiler requirement by Matlab, before using the latest compilers.
Also check whether your Cuda kit and graphics drivers are correctly installed and work seamlessly with VS. You can compile and run some .cu files under the VS environment.
If you have finished all above and changed to the correct version of compilers, follow the instructions on matheworks website to compile the mexGPUExample file. If my memory is correct, you need to set environment variables and copy the XML file to the .mex file path. Then it should work.

How to run clojure from matlab

How can I run a clojure script from matlab?
I tried following:
run matlab with jdk 1.7 and then call java
MATLAB_JAVA=/usr/lib/jvm/java-7-oracle/jre matlab
in the matlab, set classpath and use clojure compiler
javaaddpath([pwd '/lib/clojure-1.5.1.jar'])
import clojure.lang.RT
Here I got error:
Error using import
Import argument 'clojure.lang.RT' cannot be found or cannot be imported.
When I writing java class that runs clojure, everything working from console, but whould not run from matlab.
please advice.
It looks like this is a problem with Clojure not being happy running from Matlab's "dynamic classpath". I got the same error with Matlab R2014a on OS X 10.9, using either the bundled JVM or Java 1.7.0u51. But if I add clojure-1.5.1.jar to the static classpath by putting it in a custom javaclasspath.txt in the Matlab startup directory, then the Clojure classes become visible.
>> version -java
ans =
Java 1.7.0_51-b13 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
>> cloj = clojure.lang.RT
cloj =
clojure.lang.RT#77de6590
Hacking the Java classpath
You use the "class path hacking" approach in this answer to add entries to the static classpath from the Matlab command line and not have to muck around with a custom Matlab setup. The answer there involves writing a new Java class, but you can do the equivalent in pure M-code.
function javaaddpathstatic(file)
%JAVAADDPATHSTATIC Add an entry to the static classpath at run time
%
% javaaddpathstatic(file)
%
% Adds the given file to the STATIC classpath. This is in contrast to the
% regular javaaddpath, which adds a file to the dynamic classpath.
%
% Files added to the path will not show up in the output of
% javaclasspath(), but they will still actually be on there, and classes
% from it will be picked up.
%
% Caveats:
% * This is a HACK and bound to be unsupported.
% * You need to call this before attempting to reference any class in it,
% or Matlab may "remember" that the symbols could not be resolved.
% * There is no way to remove the new path entry once it is added.
parms = javaArray('java.lang.Class', 1);
parms(1) = java.lang.Class.forName('java.net.URL');
loaderClass = java.lang.Class.forName('java.net.URLClassLoader');
addUrlMeth = loaderClass.getDeclaredMethod('addURL', parms);
addUrlMeth.setAccessible(1);
sysClassLoader = java.lang.ClassLoader.getSystemClassLoader();
argArray = javaArray('java.lang.Object', 1);
jFile = java.io.File(file);
argArray(1) = jFile.toURI().toURL();
addUrlMeth.invoke(sysClassLoader, argArray);
So, use this javaaddpathstatic() instead of javaaddpath() and your code might work.

How to edit build properties of a Java Library

There seem to be some similar questions, but nothing quite specific enough, I hope this is OK.
I am wondering how to edit the build properties of the Jamod MODBUS library so as to use the RxTx API instead of the deprecated javax.comm. The Library page says this is supported:
You will need an implementation of the Java Communications API extension (javax.comm) installed to be able to run serial modbus applications.
Note that there is also support for building with the gnu.io prefix (RXTX), via the boolean build property build.serial.gnu (true will cause the build process to replace the javax.comm prefix with gnu.io in the sources used for builds).
More info here: http://jamod.sourceforge.net/development/project_build.html
I am unsure how to access this file, or the technique for doing so. Do I need to create it or edit and existing one? I have look for build.xml in the project, but no luck, and have googled many times. Any help very much appreciated.
Just open the proyect source (you can download it from rxtx) with an IDE (for example Netbeans) then replace every appearance of javax.comm by gnu.io, from rxtx, add RXTXcomm.jar library to project, and if you are using windows then copy and rxtxSerial.dll for example to C:\windows\system32.
It will work. Good Luck
The " Modbus Jamod Project - Original " folder contains the original project is available at
Web http://jamod.sourceforge.net/ . This project has a significant dependence :
[1 ] javax.comm : comm : jar :3.0 -u1
Description : The Java Communications 3.0 API is a Java extension That Facilitates develop developing platform -independent communications applications for technologies : such as Smart Cards , embedded systems, and point -of -sale devices , financial services devices , fax , modems, display terminals , and robotic equipment .
This API is not available from Oracle repositories .
That's why you have to open the " Jamod -1.2 -SNAPSHOT - sources.jar " project and recompile using other libraries for serial communication. This project is now ready to " Modbus Jamod Project with CXR " to 64 Bits.
METHOD OF SOLUTION OF DEPENDENCE
-------------------------------------------
To recompile the Jamod (Modbus Jamod Project - Original) project, you must open the project with Netbeans clear the javax.comm library , and replaced with the rxtx library. CXR This library can be selected which are in the " CXR - Serial comms Java " folder , ie :
[1 ] MFZ - rxtx -2.2- 20081207 -linux- i386
[2 ] MFZ - rxtx -2.2- 20081207 -x86_64 -linux
[3 ] MFZ - rxtx -2.2- 20081207 -win- ia64
[4 ] MFZ - rxtx -2.2- x64 -win- 20081207
[5 ] MFZ - rxtx -2.2- x86 -win- 20081207
We must take into account the following when choosing :
Windows
-------
Select a binary build - x64 or x86 (based on Which version of
the JVM you are installing to)
NOTE : You MUST match your architecture . You can not install the i386
version on a 64 - bit version of the JDK and vice - versa.
For a JDK installation:
Copy RXTXcomm.jar ---> <JAVA_HOME> \ jre \ lib \ ext
Copy rxtxSerial.dll ---> <JAVA_HOME> \ jre \ bin
Copy rxtxParallel.dll ---> <JAVA_HOME> \ jre \ bin
Linux
-----
Select a binary build - x86_64 or i386 (based on Which version of
the JVM you are installing to)
NOTE : You MUST match your architecture . You can not install the i386
version on a 64 - bit version of the JDK and vice - versa.
For a JDK installation on i386 architecture =
Copy RXTXcomm.jar ---> <JAVA_HOME> / jre / lib / ext
Copy librxtxSerial.so ---> <JAVA_HOME> / jre/lib/i386 /
Copy librxtxParallel.so ---> <JAVA_HOME> / jre/lib/i386 /
NOTE : For a JDK installation on architecture = x86_64 , just change the
i386 to x86_64 above.
-------------------------------------------------- -----------------------------------------------
After this replace the javax.comm library , the Jamod (Modbus Jamod Project - Original) project is recompiled , and the generated Jar Crossover is added.
When the Crossover project contains the library Jamod repaired , it will have to also add the RXTX library to Crossover.
Done.
-------------------------------------------------- -----------------------------------------------
There is a copy of a build.xml file if you download the source ZIP of version 1.2rc1 at http://sourceforge.net/projects/jamod/files/jamod/1.2/jamod-1.2rc1-src.zip/download
If you unzip, you will find build.xml and build-snap.xml, as well as the build.properties file, which lets you specify the build.serial.gnu.
You then just need to install ant and run it in the directory to initiate the build.
Edit: I also didn't have Apache Forrest installed, which appears to be using for generating the docs, so I needed to comment out all references to Forrest in the build.xml as well.

How do I link a 64-bit MATLAB mex file to OpenCV libraries

Normally in MATLAB I can compile a mex file which uses OpenCV functions using:
mex -O "mxFunc.cpp" -I"C:\OpenCV2.1\include/opencv" -L"C:\OpenCV2.1\lib" -lcv210 -lcvaux210 -lcxcore210 -lhighgui210
However, having switched to a 64-bit version of MATLAB, I now get unresolved symbols, e.g.
mxFunc.obj : error LNK2019: unresolved external symbol cvReleaseImage referenced in function mexFunction
How can I fix this?
System: Windows 7 64-bit; MSVC 2005; MATLAB R2010b 64-bit; OpenCV 2.1.0.
Generally: You need to recompile the used libraries in 64-bit.
As far as I know, it's not enough. If you use STL (and the OpenCV uses a lot) you need to use the same CRT version what the Matlab uses. So you need to use the same version of MSVC what the Mathworks guys...
You can check the dependency of the libmex.dll to figure out which CRT is needed. After it you need to install the proper Visual C++ (normally the free version is enough).