Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. need some help for MATLAB C++

need some help for MATLAB C++

Scheduled Pinned Locked Moved C / C++ / MFC
c++helpquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    Vincent Sim
    wrote on last edited by
    #1

    hi everybody, I am newbie in matlab C++. I am facing some problems during my work. I followed the Matlab manual in the mathworks website and wrote the code like this: --->> mwArray A = 5; int i, j = A; for (i=0; i < j; i++) cout << "Counting: " << i << endl; after compiling, the visual C++ studio shows d:\others\im\me.cpp(29) : error C2440: 'initializing' : cannot convert from 'class mwArray' to 'int' No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called there is another problem: i wrote in MATLAB C++ mArray x; mArray X1; X1 = x(1,colon()); max1=max(X1); mwArray X2; X2 =x(2,colon()); max2=max(X2); max3=max(max1,max2); after compiling, D:\others\im\me.cpp(99) : warning C4003: not enough actual parameters for macro 'max' D:\others\im\me.cpp(99) : error C2059: syntax error : ')' D:\others\im\me.cpp(103) : warning C4003: not enough actual parameters for macro 'max' D:\others\im\me.cpp(103) : error C2059: syntax error : ')' D:\others\im\me.cpp(105) : error C2440: '?' : cannot convert from 'class mwArray' to 'bool' No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called D:\others\im\me.cpp(105) : fatal error C1903: unable to recover from previous error(s); stopping compilation I would like to know how I can solve the above-mentioned problems. Thank you for your guidance. I am using MATLAB 6.1 , MS Visual C++ 6.0 , Window 2000 vincent sim

    J 1 Reply Last reply
    0
    • V Vincent Sim

      hi everybody, I am newbie in matlab C++. I am facing some problems during my work. I followed the Matlab manual in the mathworks website and wrote the code like this: --->> mwArray A = 5; int i, j = A; for (i=0; i < j; i++) cout << "Counting: " << i << endl; after compiling, the visual C++ studio shows d:\others\im\me.cpp(29) : error C2440: 'initializing' : cannot convert from 'class mwArray' to 'int' No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called there is another problem: i wrote in MATLAB C++ mArray x; mArray X1; X1 = x(1,colon()); max1=max(X1); mwArray X2; X2 =x(2,colon()); max2=max(X2); max3=max(max1,max2); after compiling, D:\others\im\me.cpp(99) : warning C4003: not enough actual parameters for macro 'max' D:\others\im\me.cpp(99) : error C2059: syntax error : ')' D:\others\im\me.cpp(103) : warning C4003: not enough actual parameters for macro 'max' D:\others\im\me.cpp(103) : error C2059: syntax error : ')' D:\others\im\me.cpp(105) : error C2440: '?' : cannot convert from 'class mwArray' to 'bool' No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called D:\others\im\me.cpp(105) : fatal error C1903: unable to recover from previous error(s); stopping compilation I would like to know how I can solve the above-mentioned problems. Thank you for your guidance. I am using MATLAB 6.1 , MS Visual C++ 6.0 , Window 2000 vincent sim

      J Offline
      J Offline
      JWood
      wrote on last edited by
      #2

      I think this one of those cryptic error codes. cannot convert from 'class mwArray' to 'int' Means that it could not find a declaration for the conversion of mwArray so it chokes on the first operation that you do on it. Either you have an outdated version of the libraries, the include file is incorrect or missing, or there is no way to converst an mwArray into an integer. The second problem looks like the macro max, which is a preprocessor directive and will go first will replace the occurances of max before it gets to it. Therefore you will have to put #undef max before it.


      My neighbours think I am crazy - but they don't know that I have a trampoline. All they see my head bobbing up and down over the fence every five seconds

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups