|
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
|
|
|
|
|
if I only want to make a stand-alone application? I need a "exe" file which can be run independently without Matlab installed. Can you give me some suggestions?
|
|
|
|
|
|
I've tried to make tutorial described in this page (http://www.codeproject.com/dll/MatlabSharedLib.asp) but compiling with my Visual Studio 6.0 I've obtained this linking error:
>Linking...
>main.obj : error LNK2001: unresolved external symbol _mlfMLMeanfunction
>Debug/main.exe : fatal error LNK1120: 1 unresolved externals
>Error executing link.exe.
>
>main.exe - 2 error(s), 3 warning(s)
what can I resolve it ?!?
PS I've just set up MVS6 to include matlab libs and headers
|
|
|
|
|
Hi,
I have an application developed entirely in matlab which uses the image processing. signal processing and the neural network toolbox. Due to the presence of the 'sim' command which is not supported when converting matlab into stand alone exe using
mcc -m <filename>
i was unable to generate the exe.
But i have heard that there is a option by which we can compile some files to C and rest remain as .m files. Include them in a VC project and then convert into in an exe. Is it possible? If so will it run without matlab. Is it enough to have the run time libraries which can be obtained from "mginstaller.exe".
If above mentioned is possible it will be of great help if someone can forward me the steps to be followed in doing so.
thanks in advance
tins
|
|
|
|
|
Hello,
I use your technic to compile my own function from matlab into dll and use it in VC++6 for the SDK of Virtools .
But I have observed that the performance was inferior in VC++ than in MAthlab !
Made I a mistake ? If yes, where can it be done ?
Can you give me some tips to optimize Matlab Code and improve performance ?
Thanks
|
|
|
|
|
The documents of MATLAB compiler noticed some techniques to improve performance. For example in loops, if the counter is an scalar (not a martix or vector of type mxArray ), the speed of execution will improve very well. See MATLAB compiler documents for more information.
A. Riazi
|
|
|
|
|
I had the same problem with "formula" when I wanted to create a DLL for "fmincon". Now wondering whether I can ever use fmincon in a C application. If not, I have to look for a source code for constrained nonlinear optimization, yuck!
|
|
|
|
|
pls give some advice with converting pascal code to matlab or calling pascal file from matlab. because i want to write a data to paralel port (matlab6.1,win98). pls reply as soon as possible.
thank you.
|
|
|
|