|
Comments and Discussions
|
 |
|
 |
Salam
I have used MATLAB® C Math Library in my project(MFC aplication in VC++ 6). the result is in a
mxarray, I have recievd error when I want to show it on an Edit box (m_edit1=M (M is a (1*1) mxarray variable type));
is there any function to convert a Mxarray variablepe to double or int type?
Regards,
Baghdadi
[email protected]
|
|
|
|
 |
hi
please help me,
I use the PDB matlab(Bioinformatics Toolbox) for read information of protein
code matlab is:
a=pdbread('c:\1ASY.pdb')
for i=1:length(a.Model.Atom)
x(i)=a.Model.Atom(i).X
y(i)=a.Model.Atom(i).Y
z(i)=a.Model.Atom(i).Z
c(i)=a.Model.Atom(i).chainID
v(i)=a.Model.Atom(i).AtomNameStruct
pdbwrite('c:\pdb1',a);
end
I follow the instruction for link c++ to matlab,
but I don't know how write the program in c++?please one example code c++ by use matlab or guide me.
I have a bad writing English,sorry,if you can help me ,please send me a message my mail ,after I write Persian text for explain what I need,
thanks and best regard.
|
|
|
|
 |
I knew matlab.h is not free library. May I ask where is an exactly webpage that I can purchese Matlab C toolbox.
Since I look in Mathwork, it has many pages.
Or anybody could suggest me other solutions to get this library
regard
CJ
|
|
|
|
 |
I want to create a figure in matlab... say a square..
On all four sides of the square are four choices for a user.. these are to be selected by keyboard by the user. A choice selected by the user is to be sent to another PC via UDP.
Can anyone help ?
|
|
|
|
 |
where can I get this header file it is not in the extern directory
|
|
|
|
 |
????? ?? ???? ?? ?????? ?? ?? ???? ?? ????? ??? ??? ? ?? ?? ????? ?? ?? dll
???????? ??? ??? ?? ??
mfile
????? ???
?? ????
|
|
|
|
 |
hi.. im a beginner to all this and have a number of questions.. first off.. i have a face recognition code which we've written in matlab.. and we hafta convert the code to C.. in that code is the svd function which we want to call in c.. so we'll hafta call that using the matlab c/c++ library from wat ive read.. now.. installing the matlab c library.. wats the procedure for that...secondly..wat would be the steps to follow? ur help in the matter would greatlyyyyy appreciated.. thanks in advance!
|
|
|
|
 |
i am interfacing fuzzy logic toolbox with VB.
i have created an m-file
function [o]=rap(x,y)
fismat = readfis('C:\Matlab7\work\dmg.fis');
o = evalfis([x y],fismat)
i have created the dll file and i have got the library in VB-project-references.
now i want to call the following matlab command in VB code
p = readfis('dmg.fis');
evalfis([x y],p)
whether it can be done?,
if yes what will be the VB code?
plz give me quick reply
|
|
|
|
 |
Assalam-o-Alaikum
I have found a strange problem when using the funsction mlfRoots. I use this funtion in a loop. Sometimes it causes the whole application to terminate without any message to user. Do you have any idea to handle this situation.
Regards
Zia
|
|
|
|
 |
Hi!! I want to use the Matlab C Functions in cygwin but I don't know how, Can syou help me please?
|
|
|
|
 |
Hi! I've downloaded your demo but I cannot compiling it because it tells me it cannot find the matlab.h file. I've already installed the Matlab Compiler but I still cannot find that file. I've downloaded the file from a web page but I get errors:
MatlabConsole.cpp
C:\Documents and Settings\Laura\Bureau\MATLAB_C_API\MatlabConsole.cpp(41) : error C2065: 'memcpy' : undeclared identifier
C:\Documents and Settings\Laura\Bureau\MATLAB_C_API\MatlabConsole.cpp(45) : error C2065: 'mlfPrintMatrix' : undeclared identifier
C:\Documents and Settings\Laura\Bureau\MATLAB_C_API\MatlabConsole.cpp(51) : error C2065: 'mlfTimes' : undeclared identifier
C:\Documents and Settings\Laura\Bureau\MATLAB_C_API\MatlabConsole.cpp(51) : error C2440: '=' : cannot convert from 'int' to 'struct mxArray_tag *'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
C:\Documents and Settings\Laura\Bureau\MATLAB_C_API\MatlabConsole.cpp(57) : error C2065: 'mlfMagic' : undeclared identifier
C:\Documents and Settings\Laura\Bureau\MATLAB_C_API\MatlabConsole.cpp(57) : error C2065: 'mlfScalar' : undeclared identifier
C:\Documents and Settings\Laura\Bureau\MATLAB_C_API\MatlabConsole.cpp(57) : error C2440: '=' : cannot convert from 'int' to 'struct mxArray_tag *'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
C:\Documents and Settings\Laura\Bureau\MATLAB_C_API\MatlabConsole.cpp(73) : error C2065: 'mlfConv' : undeclared identifier
C:\Documents and Settings\Laura\Bureau\MATLAB_C_API\MatlabConsole.cpp(73) : error C2440: '=' : cannot convert from 'int' to 'struct mxArray_tag *'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
C:\Documents and Settings\Laura\Bureau\MATLAB_C_API\MatlabConsole.cpp(78) : error C2065: 'mlfRoots' : undeclared identifier
C:\Documents and Settings\Laura\Bureau\MATLAB_C_API\MatlabConsole.cpp(80) : error C2065: 'mxDestroyArray' : undeclared identifier
Error executing cl.exe.
MatlabConsole.exe - 11 error(s), 0 warning(s)
I don't know what I'm doing wrong. Please help me.
Thanks
Laura
|
|
|
|
 |
Hi! It's me again.. I cannot find Matlab.h in my computer.. Where is it? I thought il will be in the Matlab firectory but is not..I've read another message which ask the same question and the answer says to install the compiler toolbox but I 've already done it and I cannot find it..
Thank you
Laura
|
|
|
|
 |
Hi! I'm trying to use the Matlab functions for C with cygwin to use the code in Linux later.
When I work with cygwin and I try to use that function in several codes and I always get the same error:
$ make
g++ -Wall -g -O3 -I. -I../include -I/usr/cad/systemc/systemc_2_1.oct_12_2004.be
ta/include -I/usr/cad/systemc/systemc_2_1.oct_12_2004.beta/src -o ../obj/moduleM
atrix.o -c ../src/moduleMatrix.cpp
../src/moduleMatrix.cpp:108: error: parse error at end of input
make: *** [moduleMatrix.o] Error 1
Everybody has told me it was an error because of the lack of a ( or a }, but I've already check it and it's not. I've read your instructions to use Matlab functions for C but I don't understand:
1. I have to write "#include " at the end of the stdafx.h" but I've found two differents files in the folders: "matlabroot/toolbox/matlab/winfun/mwsamp" and "matlabroot/toolbox/matlab/winfun/mwsamp2".
2. I have to add the desires libraries to my projet but I don't know how to do it in cygwin or Linux because it's the first time I use them.
It would be great if you could help me.Thank you
The code I've used to test the correct operation is enclosed here:
mxArray *im[50];
mxArray *name=mxCreateString("image068.jpg");
// Transform image to matrix
mexCallMATLAB(1,&name;, 2, im, "imread");
// imag[0] would be the image, imag[1] the map.
Laura.
|
|
|
|
 |
Hi,
I am using MATLAB 7.3.0 with Compiler. However I can not find the matlab.h or other libfiles. The Tech note says that Compiler includes the Matlab C Math Library, which is no longer supported as a independent product. (Section 4 of this address: http://www.mathworks.com/support/tech-notes/1600/1622_files/1622_R13.html)
The reading of Compiler manual is dizzy- It seems that one need to wrap anything into .m files, compile it into .dll, and then call it in C code. In contrast, the old document of Matlab C Math library just let youu include the head file and use its functions!!! (http://www.isds.duke.edu/comp/internal/matlab/toolbox/mathlib/cmathug/cmathug.html)
So is there any easy way to use Matlab functions for my MATLAB 7.3.0?
Thanks.
Michael
|
|
|
|
 |
How can I convet C file to matlab?
|
|
|
|
 |
Please help me in c to matlab conversion.
|
|
|
|
 |
Hi,
The articles written by you really wonderful and are very much helpful...
In our project we need to make use of quadprog function for the optimization of a problem...
Is there any way to directly call the quadprog function from Visual Basic 6.0??
Or else are there any other ways to do the same thing...
Awaiting your immediate reply...
SL
|
|
|
|
|
 |
salam Mr Riazi
I like to know completely, what do I need for exchangeing C# or C++ or C to m.file,Is it possible? is there any difference between different types of C? and vice versa.
and for making an interface between C and m.file what i must do ? what I need?
I use matlab 7
[email protected] is my mail
Please help me,really I need replies of these questions.
I am looking forward for ur guidence.
Best Regards
melika
|
|
|
|
 |
i made a program with matlab gui(guide user interface).
it works so right. i have two file first with *.fig extention
second with *.m extention
my problem is how to make my program a standlone application (with *.exe extention)..
how to convert fig file to exe file in matlab??
thanks..
uLTraSLan-uNi
uLTraSLan-uNi
|
|
|
|
 |
Hi!
I have a vc++ code (vs 6.0) for a numerical simulation where it generates the results as *.dat and *.gnu files and plots them by calling GNUPLOT. However, the quality comes out really poor and they cannot be used to put for any publication document. I need to use matlab graphics instead by calling matlab functions from my vc++ code.
Could you please help me with how should i call matlab from vc++ code to plot the results.
I am anxiously waiting for any kind of help in this regard.
thanks
|
|
|
|
 |
Hi,
There are two ways:
1- Using your generated .dat file in MATLAB and plot them after loading.
2- Reading my other article: MATLAB Engine API[^]
Best regards,
A. Riazi
|
|
|
|
 |
Hi,
I have a big problem using the matlab library so as to import .mat files in my programs.
I would like to get the contents of the numeric arrays included in my .mat files. I'm trying with the function "matGetPr", Ihave no error during compilation but, at the execution, the console is closing with an error . Does somebody know how to fix the thing?
Thank you very much
Olivier
|
|
|
|
 |
Plz tell me how to access the data in mat files
|
|
|
|
 |
Dear Riazi.
Thank you for your very useful articles on Matlab and C/C++ interfacing. I am using Matlab 6.5 C Engine Library together with LCC compiler. My problem is that I have to call an ODE solver of Matlab whose first argument required is name/address of an m-file which contains equations to be integrated. However I have written that file in C language. I donot know how to call it by the ODE solver.
I appreciate your valuable advice in this regard.
yours sincerely,
MUHAMMAD JAVAID
([email protected])
muhammad javaid
|
|
|
|
 |
Hi, Can anybody send the matlab header file matlab.h to me? This is my e-mail address [email protected] Regards, Kamrul
|
|
|
|
 |
You must install MATLAB Compiler Toolbox.
Best regards,
A. Riazi
|
|
|
|
 |
I have a compiler installed and the version is 2.4.1 .
my matlab vertion is 7.4
were will i find the matlab.h header
Sindhu Krishnan
Software Engineer
|
|
|
|
 |
Hi!! I cannot find the matlab.h file either, but I've found an address where you can download it:
http://www.koders.com/c/fid228279372BF42AA27A4F9EA1967C1FD2C8EBB73A.aspx
But I've tried to use it and I have compiling errors but It is may be a cause of my code.
Good luck.
Laura
|
|
|
|
 |
My problem is explained as following (as described in readme.txt):
This is a simple demo to show the problem. (Matlab 6.5)
function [x] = fcn_update_m(x)
x = x + 1.3;
mcc -t -L C fcn_update_m.m to produce fcn_update_m.c
This function is used to update the state 0, xD[0] = xD[0] + 1.3;
If I don't use the functions from Matlab C library (eg, mlfScalar,mlfFcn_update_m,mxGetPr), the model is OK in external mode.
But if I use the functions from Matlab C library (eg, mlfScalar,mlfFcn_update_m,mxGetPr), running the model in external mode will reboot the computer even though 'build' the model is OK.
Using
//m = mlfScalar(xD[0]);
//a_out = mlfFcn_update_m(m); /* a_out = xD[0] + 1.3;*/
//a_out_c = mxGetPr(a_out);
//xD[0] = *a_out_c;
to replace
//xD[0] = xD[0] + 1.3;
I packaged the whole folder. But how can I upload the package?
It seems no attachment file allowed here.
|
|
|
|
 |
Hi Riazi,
Hope you can give me some suggestions about the problem.
I encountered a serious problem when I using real time target model in
simulink.
1. As I wrote all my algorithms in m files, I had to translate them into C
code using command 'mcc -t -L C xxx.m'. Then it contains many Matlab C
library functions, like mlfDoubleMatrix().(form a matrix)
2. Using s-function builder to cooperate the algorithm into real time
target model in simulink which has a NI data acquisition board.
3. 'Build' the model is OK.
4. 'Run' the model caused the computer to reboot. I noticed if I deleted
all the functions from Matlab C library, like mlfDoubleMatrix(), there is
no problem. If I added one Matlab C function, eg. mlfDoubleMatrix(), into
update subroutine of the s-function builder, 'Run' the model will cause
the computer to reboot again.
Software is:
Matlab version 6.5.0.180913a Release 13
June 18, 2002
Corresponding Simulink version.
Hope to hear from you soon!
Thank you!
Best regards,
Bin
e-mail: [email protected]
|
|
|
|
 |
Thanks man,
Now i am able to read a mat file now,
actually the file is a configuration file which contain data
in the format of structure,
meance a structure repeatedly contains the structure and in that again a structure and so on,
i have called it recursively i could able to retrive the data now but i can retirve the structure type of data only the other data i can not able to read ...
when i try to read a string or char type of data using mxGetString()
i am getting a runtime application error...
if i use the a code snippet made by u i can able to retrive it as u create that data and read it,
when i want to read a existing data i am facing the problem, same for numeric , double data type
Pls help me out
i need it very urgent as i need to complete it very soon pls help me out...
the code snippet will be a great help...
i am sending u the code which i have writeen.
int information(mxArray *pa, const char *name)
{
int j, status;
const char *type;
char str[256];
mxArray *pb;
int bufsize, buflen;
if (pa == NULL)
{
printf("Error reading in file \n");
return(1);
}
/* Diagnose header pa. */
printf("\narray '%s' has %d dimensions, %d fields, %d elements\n",name, mxGetNumberOfDimensions(pa),
mxGetNumberOfFields(pa), mxGetNumberOfElements(pa));
for (j = 0; j < mxGetNumberOfFields(pa); j++)
{
pb = mxGetFieldByNumber(pa, 0, j);
name = mxGetFieldNameByNumber(pa, j);
type = mxGetClassName(pb);
bufsize = mxGetNumberOfElements(pb);
printf("%27s %9s %2d", name, type, bufsize);
if (mxIsChar(pb) )
{
printf("Character Type");
// buflen = (mxGetM(pb) * mxGetN(pb) * sizeof(mxChar)) + 1;
// status = mxGetString(pb, str, 255);//sizeof(buflen));
//printf ("%10s",str);
}
if (mxIsDouble(pb) )
{
printf("Double Type...");
}
if (mxIsStruct(pb) )
{
printf("Struct Type...");
information(pb, name);
}
if (mxIsCell(pb) )
{
printf("Cell Type...");
information(pb, name);
}
printf("\n");
}
printf("\n");
//mxDestroyArray(pa);
return(1);
}
|
|
|
|
 |
Hi,
I have made a C program which call matlab. When I compile my projet, I always have the same error for each function I have called in the file engine.h . [Linker error] undefined reference to....
I use DEV C++.
I suppose that I have not add the right librairies to the project but I don't know which I must use and incorporate to the project.
If somebody can help me....
|
|
|
|
 |
I don't have the above mentioned files with me,
and due to that i am getting the linker errors for all the mx variables ,
pls help me out i want to integrate c and matlab
plssssssssssssssssss
thanks and ragards,
Gajendra Agrawal
|
|
|
|
 |
What is your MATLAB version?
A. Riazi
|
|
|
|
 |
i have matlab 7.0.1 version.
I want to know one more thing,
if i want to use matlab c API in my application what i need to do, whether i need to purchase it or can i use it directly, and if i have some problems related to it will u assist me as u have designed it?
can i get details of this API??
pls reply me ASAP...
|
|
|
|
 |
1- You must buy the Compiler Toolbox.
2- If I can help you I will do.
Best regards,
A. Riazi
|
|
|
|
 |
I'm having problems trying to use it with matlab 7.0 or a version above. The the last versíons I don't have this problem. Can you inform me why is this problem happening?
MAT
|
|
|
|
 |
hey, i think i ve got the same problem here.. i use matlab 5.3.
|
|
|
|
 |
I have installed the Maltab Compiler and I've found the libmatlbmx.lib and libmatlb.lib files in: C:\Program Files\MATLAB\R2007a\extern\include in my case, in yours probably: C:\Program Files\MATLAB\R2007a\extern\include
Laura
|
|
|
|
 |
Does anyone know how to use mxArrays in C#.
Thanks
|
|
|
|
 |
Hi folks,
here's some example code for adressing Cell Arrays.
Best Regards,
Wätzold
CODE=============
#include
#include
#include
#include
#include "/usr/local/bin/matlab/extern/include/engine.h" //*or whereever
this file is on
your System*//
#define BUFSIZE 256
using namespace std;
int main()
{
Engine *ep;
mxArray *T = NULL, *result = NULL, *cell = NULL;
char buffer[BUFSIZE];
cout << "Starting MATLAB...\n";
if (!(ep = engOpen("/usr/local/bin/matlab/bin/matlab"))) {
fprintf(stderr, "\nCan't start MATLAB engine\n");
return EXIT_FAILURE;
}
cout << "...MATLAB started!\n";
engOutputBuffer(ep, buffer, BUFSIZE);
int ndims[] = {3,4};
T = mxCreateCellArray(2,ndims);
engPutVariable(ep, "T", T);
engEvalString(ep, "T = {0.0,1.0,2.0;3.0, 4.0,5.0;6.0, 7.0,8.0;9.0, 10.0,11.0}");
T = engGetVariable(ep, "T");
cout << buffer + 2 << "\n";
int n;
double celldb[1];
for(n=0; n<12; n++){
cell = mxGetCell(T,((4*n)%12 + (4*n)/12));
memcpy( celldb, mxGetPr(cell), sizeof(double));
cout << celldb[0] << " ";
if((n+1)%3==0) cout << "\n";
}
cout << "\nDone!\n";
engClose(ep);
return EXIT_SUCCESS;
}
=============END CODE
|
|
|
|
 |
thanks
--
Aurelien
|
|
|
|
 |
does anybody know of a way to translate code written for matlab 6.0 into standard c/c++? I was given some simple code that was written in matlab but not being a matlab coder, I would like to just translate it and run it in c/c++
c6jones720
|
|
|
|
 |
hello
I have my own Matlab .m files, which I have built
into C++ library of .obj files using >> mcc -B cpplib. But
how do I use them in my C++ project (in VC++ 6.0)?????
-- modified at 23:54 Sunday 6th November, 2005
|
|
|
|
|
 |
Even i would like to know the answer for a similer question
I have my algorithms written in matlab
i want to write a program in c which will give input to my matlab code and gets the output from my matlab code.
i dont want to do it using MATLAB engine. Can it be possible using a DLL and how if its possible.
Sindhu Krishnan
|
|
|
|
 |
Why do I have a Compiling error C2065: 'memcpy' : undeclared identifier
When I delete the segments of the 'memcpy' functions,this program can Compile and Link sucessfully.why?
|
|
|
|
 |
Just include memory.h.
Best regards,
A. Riazi
|
|
|
|
 |
|
|
General News Suggestion Question Bug Answer Joke Rant Admin
Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.
|
Type | Article |
Licence | |
First Posted | 23 May 2003 |
Views | 494,254 |
Bookmarked | 77 times |
|
|