|
I got the error messages in visual basic.
VC ++ compiled with out errors.
When I try to use the dlls, either from matlab or vc++ i got errors, saying that the function didn't exist, or the entry point error in vb 6.
Also, I read your articles, which are very good, but I don't seem to have the com toolbox in matlab. I have version 6.0
I appreciate your help.
skin the sun, fall asleep, wish away, soul is cheap, lesson learnt, wish me luck, sooth the nerve, wake me up
|
|
|
|
|
Guys,
I compiled my .M file into mex DLL. Now it has only one function to export: mexLibrary
How can I call that DLL?
When I am compiling it into shared library it gives me a lot of errors I do not want to deal with.
But if it would compile, I could have initialization functions like
.....Initialize
.....Terminate
exported from that library.
Please help!
Thanks!
|
|
|
|
|
Yerbolat wrote:
I compiled my .M file into mex DLL. Now it has only one function to export: mexLibrary
Mex Dlls are only suitable for MATLAB. No other languages can benefit from it. Mex files are suitable for speeding up the calculation in MATLAB.
If you want to create a dll from your m-file that can be called from another language, you must compiled it as shared Dll.
A. Riazi
|
|
|
|
|
this is my function
funtion a=X(b)
a=b*2;
funtion c=Y(d)
e=X(d);
c=e*3;
i known you're very busy,but can you show me more clearly;)
it's very important to me
thank you
dnqhung
|
|
|
|
|
HI
I have an DLL file that I want to open in MATLAB. I want to use output from DLL for further processing in MATLAB. DO anyone know how this is possible?
MItesh
|
|
|
|
|
|
Hello,
Does conversion to C-code from MATLAB m-files for these functions yield a significant speed increase? Ive heard that Matlab is wasteful of memory, especially in large functions with many loops.
thanks!
|
|
|
|
|
With some tricks your answer is yes. You can improve speed of MATLAB by compiling it. If you use C API directly with optimized code the speed is improved very well.
A. Riazi
|
|
|
|
|
Cannot include mat.h,matlab.h,matlab.
i'm new to VC++ and matlab,so i can't find why this error is coming.
please tell me!
(i'm using Matlab 6.5 R13 and VC++6.0,and I installed complete Matlab,VC++)
fatal error C1083: Cannot open include file: 'matlab.hpp':
No such file or directory
|
|
|
|
|
try followings:
option->directories->inclues files add your matlab path
D:\MATLAB6P5\EXTERN\INCLUDE\CPP
D:\MATLAB6p1\extern\include
|
|
|
|
|
|
Hello Riazi
this is my function
------------------------
function sum = matbs( a, b )
% sum
sum = a + b
------------------------
i save it as "matsum.m"
mcc -t -L C matsum.m
mcc -t -L Cpp matsum.m
(matsum.cpp matsum.hpp)
mcc -t -W lib:sum -T link:lib matsum.m
and there are 9 files
--------
matsum.c
matsum.h
sum.c
sum.exports
sum.h
sum.mlib
sum.dll
sum(exp file)
sum(lib file)
------------
i use sum.dll sum(lib file) and sum.h to VC6.0
i created project based on single dialog
1:copy the sum.dll and sum.lip,sum.h to the project directory(sum.dll to debug directory)
2:
in cpp
#include "matlab.h"
#include "sum.h"
3:project|setting->linking->object|library modulse :add sum.lib
-----------
void CXxmatlabDlg::OnButton1()
{
int a;
a=sum(1,2);
//but there is error :\my program\c\xxmatlab\xxmatlabDlg.cpp(179) : error C2065: 'sum' : undeclared identifier
CString str;
str.Format("%d",a);
AfxMessageBox(str);
}
-----------
why not still to use the sum function??
|
|
|
|
|
I think your function name must be the same as it's file name. Also I think you must use mlfSum instead of sum .
A. Riazi
|
|
|
|
|
thanks for your reply;
but there is another error;
-----------------
void CXxxmatlabDlg::OnButton1()
{
int a;
a=mlfSum(1,2);//error
CString str;
str.Format("%d",a);
AfxMessageBox(str);
}
----------------------------
error
:\my program\c\xxxmatlab\xxxmatlabDlg.cpp(177) : error C2664: 'mlfSum' : cannot convert parameter 1 from 'const int' to 'struct mxArray_tag *'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
Error executing cl.exe.
----------------
would you mind telling me your email,i want to email my programs to you.
thanks very much.
|
|
|
|
|
Change the lines
int a;
a=mlfSum(1,2);
to
mxArray* a;
a=mlfSum(1,2);
A. Riazi
|
|
|
|
|
thanks
i have tryed this way but the erro still.
---------
mxArray* a;
a=mlfSum(1,2);
CString str;
str.Format("%d",a);
AfxMessageBox(str);
----------
error
C:\Documents and Settings\Administrator\×ÀÃæ\xxxmatlab\xxxmatlabDlg.cpp(178) : error C2664: 'mlfSum' : cannot convert parameter 1 from 'const int' to 'struct mxArray_tag *'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
Error executing cl.exe.
|
|
|
|
|
OK. Change the first parameter to mlfScalar(1) . In other hand:
a=mlfSum(mlfScalar(1), mlfScalar(2));
A. Riazi
|
|
|
|
|
thanks
but i am sorry to go on this question
-----------
mxArray* a;
a=mlfSum(mlfScalar(1), mlfScalar(2));
// a=mlfSum(1,2);
CString str;
str.Format("%d",a);
AfxMessageBox(str);
---------------
compile is ok
but
build is still error
Linking...
xxxmatlabDlg.obj : error LNK2001: unresolved external symbol _mlfSum
xxxmatlabDlg.obj : error LNK2001: unresolved external symbol _mlfScalar
Debug/xxxmatlab.exe : fatal error LNK1120: 2 unresolved externals
Error executing link.exe.
xxxmatlab.exe - 3 error(s), 0 warning(s)
i try to add extern mlfSum(); and extern mlfScalar() is not still ok.
how can i get the right result=3??
thanks
|
|
|
|
|
OK. Now you should add some library (*.lib) to your project. If you have sum.dll, you should also have sum.lib, add this to your project. Also you must add some other libraries of MATLAB Math toolbox. For this see my demo application again.
A. Riazi
|
|
|
|
|
i added
#pragma comment(lib, "libmx.lib")
#pragma comment(lib, "libmatlb.lib")
#pragma comment(lib, "libmat.lib")
#pragma comment(lib, "libmmfile.lib")
to my program
compile and build is ok
but the result is wrong , the result is not 3 ,while is randly number.
|
|
|
|
|
Hello Riazi
this is my function
------------------------
function sum = matbs( a, b )
% sum
sum = a + b
------------------------
i save it as "matsum.m"
mcc -t -L C matsum.m
mcc -t -L Cpp matsum.m
(matsum.cpp matsum.hpp)
mcc -t -W lib:sum -T link:lib matsum.m
and there are 9 files
--------
matsum.c
matsum.h
sum.c
sum.exports
sum.h
sum.mlib
sum.dll
sum(exp file)
sum(lib file)
------------
i use sum.dll sum(lib file) and sum.h to VC6.0
i created project based on single dialog
1:copy the sum.dll and sum.lip,sum.h to the project directory(sum.dll to debug directory)
2:
in cpp
#include "matlab.h"
#include "sum.h"
3:project|setting->linking->object|library modulse :add sum.lib
-----------
void CXxmatlabDlg::OnButton1()
{
int a;
a=sum(1,2);
//but there is error :\my program\c\xxmatlab\xxmatlabDlg.cpp(179) : error C2065: 'sum' : undeclared identifier
CString str;
str.Format("%d",a);
AfxMessageBox(str);
}
-----------
why not still to use the sum function??
|
|
|
|
|
Hello Riazi,
I would like to ask you a question. If you are knowledgeable about Matlab-Simulink, i need to know how to make an executable with the simulink model. I am using the real time workshop and also the realtime embedded target is tms320c6711. The model is only a FIR filter with output and intput DAC and ADC lines. matlab uses code composer studio to build the code and download to the hardware but that takes too much time. Do you know if, through code composer or visual studio i can make the .exe file
Thank you
Ranj
|
|
|
|
|
Hi,
Sorry, I have not any experience with real time workshop and simulink.
A. Riazi
|
|
|
|
|
mcc -t -L C -W lib:imageprocessLib -T link:lib imageprocess.m libmmfile.mlib
Creating library imageprocessLib.lib and object imageprocessLib.exp
imageprocess.obj : error LNK2001: unresolved external symbol _mlfNEdge
imageprocess.obj : error LNK2001: unresolved external symbol _mlfRGB2GRAY
imageprocess.obj : error LNK2001: unresolved external symbol _mlfImwrite
imageprocess.obj : error LNK2001: unresolved external symbol _mlfNImread
imageprocessLib.dll : fatal error LNK1120: 4 unresolved externals
MBUILD.BAT: Error: Link of 'imageprocessLib.dll' failed.
----------------------------------matlab code-------------------
function imageprocess(x)
I1=imread(x);
imwrite(I1,'translated.png','png');
I2=imread('translated.png');
I=RGB2GRAY(I2);
BW=edge(I,'canny');
imwrite(BW,'filtered.jpg','jpg');
=================================================================
in fact, I want to make it as a stand-alone application, and rum mcc -p imageprocess to create a exe file. however, it can only make a translated png, the program compliants that "image/private/histc.dll" cannot be found. I have already included them, can anyone help me? thanks.
|
|
|
|
|
First try to compile Edge, RGB2GRAY, Imread and Imwrite functions to MEX-file (dll) then use the above command to compile your code. In this case you must add library of created MEX-files (those who have lib extension) to mcc command.
A. Riazi
|
|
|
|