Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple question

Status
Not open for further replies.

staccato

Computer
Joined
Dec 6, 2002
Messages
3
Location
BE
Hello ,

I need the Sign() function in C++
so I added :
#include "matlab.hpp"
at the header file of my program

now VC ++ doesn't find any "matlab.hpp" , and so do I ...

yes , I've installed MathLab , R12
so what's the problem ??

tankzalot.
 
Is it in the right directory?

TTFN
 
what do you mean ??
matlab.hpp??

I haven't got any matlab.hpp ?? :-(
I do got matlab.h ...

my matlab dir = D:\matlabR12

what directory do you mean ??
(I'm really new at matlab so thanx for the patience)

thanx!!
 
Where did you come up the the name "matlab.hpp" from? In VC "xxx.hpp" usually refers to a printer driver.
I have all available help files for Matlab loaded and search does not find anything about "matlab.hpp". But, there is a matlab.h!
 
I don't understand why you added the include line if you don't have the file. C-language include files are actual files that reside in the default include directory for the compiler, unless there is a means of directing the compiler to search elsewhere.

I'm not getting the feeling that you understand C sufficiently for you to do this. Why not simply write your own sign function? Unless you have a throughput problem?

sign(x) = x/|x| for x<>0
or
sign(x) = if(x<>0,if(x>0,&quot;+&quot;,&quot;-&quot;),&quot;x=0&quot;)
or several other possibilities.

TTFN
 
&quot;matlab.hpp declares the MATLAB C++ Math Library's data types and functions. matlab.hpp includes iostream.h, which declares the input and output streams cin and cout. stdlib.h contains the definition of EXIT_SUCCESS&quot;

this is the explanation of matlab.hpp .
__
-> more matlab.hpp
___
.hpp stands for c++ header

___
I actually did write my own sign() function ,
but I'm still not wiser on how to use matlab with C++ ??
 
This line must be in your matlab path:

C:\matlab6p5\extern\examples\cppmath

adjust the C:\ and the matlab6p5 to whatever your directory names are.

Otherwise, matlab will not be able to find the C++ math library. Which appears to be your problem.
 
In order to be able to use MATLAB C/C++ Math Library functions in your c++ code you have to setup you compiler

In your project setteings you should do following
1) add lib files to your project settings under link bookmark
Go to MATLAB help
Using the C++ Math Library: Getting Started: Linking Applications Without mbuild (I strongly suggest you to read Getting started and Fundamential of the help)
to see which lib files to connect.
2) Also check &quot;Disable Language extensions&quot;
3) add preprocessor definition &quot;MS_WIN_API&quot;
4) and still I had to &quot;force file output&quot;

In Tools -> Options -> directories put all the nessessary paths to the libraries and include files

It doesn't worth it just for a sign function. ;-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top