×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Simple question

Simple question

Simple question

(OP)
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.

RE: Simple question

Is it in the right directory?

TTFN

RE: Simple question

(OP)
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!!

RE: Simple question

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!

RE: Simple question

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,"+","-"),"x=0")
or several other possibilities.

TTFN

RE: Simple question

(OP)
"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"

this is the explanation of matlab.hpp .
__
http://www.google.be/search?q=matlab.hpp&ie=UTF-8&oe=UTF-8&hl=nl&meta=
-> 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++ ??

RE: Simple question

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.

RE: Simple question

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 "Disable Language extensions"
3) add preprocessor definition "MS_WIN_API"
4) and still I had to "force file output"

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.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources