How can i introduce a function in matlab?

I want introduce the function "mtimesx" in matlab but i don´t know how
I tried it since import file but i have errors
My version is r2008a and i have windows 7
thanks

1 个评论

What do you mean by introduce a function ? Do you want to add function in matlab so it can be run from anywhere ?

请先登录,再进行评论。

 采纳的回答

You will need to install a supported compiler; see http://www.mathworks.com/support/compilers/release2008a/
Then at the MATLAB command line, give the command
mex -setup
to select the compiler.
Then, download mtimesx and unzip it into a new directory under your Documents and Settings folder.
In MATLAB, "cd" to that folder and then at the MATLAB command line give the command
mtimesx_build
that should build the program.
After that you might possibly need to use pathtool to add the new directory to your MATLAB path.

更多回答(2 个)

thanks but i have this problem
Build routine for mtimesx
... Checking for PC
... Finding path of mtimesx C source code files
... Found file mtimesx.c in C:\Program Files\MATLAB\R2008a\sys\lcc\mtimesx\mtimesx.c
... Found file mtimesx_RealTimesReal.c in C:\Program Files\MATLAB\R2008a\sys\lcc\mtimesx\mtimesx_RealTimesReal.c
... Opened the mexopts.bat file in C:\Users\Gusa\AppData\Roaming\MathWorks\MATLAB\R2008a\mexopts.bat
... Reading the mexopts.bat file to find the compiler and options used.
... LCC is the selected compiler
... OpenMP compiler not detected ... you may want to check this website:
http://openmp.org/wp/openmp-compilers/
... Using BLAS library lib_blas = 'C:\Program Files\MATLAB\R2008a\extern\lib\win32\lcc\libmwblas.lib'
... Now attempting to compile ...
mex('C:\Program Files\MATLAB\R2008a\sys\lcc\mtimesx\mtimesx.c',lib_blas,'-DCOMPILER=LCC')
it can´t find C:\Program Files\MATLAB\R2008a\sys\lcc\mtimesx\mtimesx.exp
it cant´find C:\Program Files\MATLAB\R2008a\sys\lcc\mtimesx\mtimesx.lib
... mex mtimesx.c build completed ... you may now use mtimesx.
then i introduce:
C = mtimesx(a,b)
??? Undefined function or method 'mtimesx' for input arguments of type 'double'.
what can i do?
yes, i installed it and i used mex-setup but i have this error
The mex command failed. This may be because you have already run mex -setup and selected a non-C compiler, such as Fortran. If this is the case, then rerun mex -setup and select a C/C++ compiler
before:
Select a compiler: [1] Lcc-win32 C 2.4.1 in C:\PROGRA~1\MATLAB\R2008a\sys\lcc\bin [2] Microsoft Visual C++ 2005 Express Edition in C:\Program Files\Microsoft Visual Studio 8
[0] None
Compiler: 2
Please verify your choices:
Compiler: Microsoft Visual C++ 2005 Express Edition Location: C:\Program Files\Microsoft Visual Studio 8
Are these correct [y]/n? y
*************************************************************************** Error: The Microsoft Platform Software Development Kit (SDK) was not found.
Microsoft Visual C++ 2005 Express Edition requires that the SDK is
installed properly. MEX uses the environment variable "MSSdk" to
find the SDK. If it is installed properly, please verify that the
environment variable "MSSdk" points to the correct location.
Otherwise, install the SDK and try again.
How can i install SDK???
thanks

类别

帮助中心File Exchange 中查找有关 C Shared Library Integration 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by