MATLAB Conversion Help (to c or c++)

  • MATLAB
  • Thread starter starfighter
  • Start date
  • Tags
    Matlab
In summary: Yes, you can call a MatLab compiled object from C/C++.B) Compiling MatLab code to shared librariesMatLab allows you to compile your code to shared libraries, and then call these libraries from other code.C) Porting an existing MATLAB code to C/C++You can port your existing MatLab code to C/C++, or write new code in C/C++ to call your MatLab code.D) Getting an outside contractor to do the codeYou can get an outside contractor to do the code, or work in a project management roll and get an outside contractor to do the code.
  • #1
starfighter
2
0
Hi

I have made an application in MATLAB, well the technical part with the use of the tool-kits built in.

Now i need to get that information from MATLAB in the form of c or c++ so i can import it into visualstudio and made a GUI and add features such as database and demo/reg models.

Thing is, i have no idea how or if its even possible?

All i can see is that it can be made into a format so it can be called as a com object.

I am looking at going over to MAC, any ideas if i can compile this so i can be run via X-Code which i am led to think is Objective-C?

Thanks for any help. If you think another forum might be better too, please tell me and i will move it, or repost it...
 
Physics news on Phys.org
  • #2
I'm so horribly confused. Do you need to port (translate) your existing MATLAB code to C/C++ or make your MATLAB code callable from C/C++?

You can't run stuff compiled in visual studio on a mac 'cause vs uses native windows stuff when compiling, but you can totally run C/C++ on mac.
 
  • #3
starfighter said:
Hi

I have made an application in MATLAB, well the technical part with the use of the tool-kits built in.

Now i need to get that information from MATLAB in the form of c or c++ so i can import it into visualstudio and made a GUI and add features such as database and demo/reg models.



I'm afraid I don't have much of an idea what you're talking about either. Firstly, Matlab has its own GUI creation tools that you can use to set up GUIs to control your code; you can then generate standalone executables using Matlab that bundle your application code and the GUI code for deployment to users who don't have Matlab installed.

What I think you're really after is the following. Matlab allows you to compile Matlab code to shared libraries that you can then call from other code. It's perfectly conceivable that you could write, say, Matlab code to implement an optimization library, compile it to a shared library using the Matlab compiler, and then call this library from code written in Visual Studio. However, although the latest versions of Matlab make this much easier than it was in the past, it's far from trivial, and the fact that your question is so vague makes me suspect that you might find it challenging.

See the Matlab Compiler docs for much more information on this, including examples. There are loads of relevant docs on this precise topic in the Matlab help system.

starfighter said:
I am looking at going over to MAC, any ideas if i can compile this so i can be run via X-Code which i am led to think is Objective-C?

XCode is a development environment on OS X which allows you to write code in Java, C/C++, Objective C, Python, Ruby, and so on. It's a decent tool for creating software on the Mac but it's nothing in comparison to Visual Studio. Calling Matlab shared libraries on a Mac is possible but you'll need to have experience with using threads to create and manage access to the library safely. Again, this is far from being trivial and isn't something an inexperienced programmer could do without difficulty.
 
  • #4
Sorry, i am a master of been vauge, i am really not as uneducated as i may sound.

- What I Have

I have an application i have made in MatLab. I can't say what it is without making you sign an NDA, and even then I doubt i could get approval, so will have to just call it an "application".

Its using the imaging, and financail toolbox within MatLab, and it all runs like i want it to, so the MatLab side is fine.

- What I Want

I want to put my MatLab application on a mobile platform. We are using Blackberry, IPhone and Windows Mobile.

I need to port it to "one" for proof of concept, but it would be good if that "one" was the IPhone as its got 70% usuage in my company, followed by blackberry, and just a few with the Windows Mobile Platform.

I have took on more than I am experienced with, I am good at MatLab Code, and good at C, but that's about it.

So what I will do is work in a project management roll and get an outside contractor to do the code.

- Problem

I don't have a clue on the technical side, and i want to understand how one can use MatLab code, say on the Iphone.

I would like to understand what's involved, for example compile MatLab to ? and then use X-Code to program the application.

I understand i have to join apple dev to get the sdk and way to distribute, which is one thing.

So is it

A) Possible to call a MATLAB compiled object on iphone?

B) Using X-Code?

C) Is there a better way (web app)?

D) Is it a simple case of compiling MatLab code, and then calling it from X-Code?


Once i get a feel of what involved, i can get some quotes from coders, if any are here, i would be glad to talk business, but i realize this is not a freelance website and don't want to violate any rules here.
 
  • #5



Hello,

It is possible to convert MATLAB code into C or C++ using the MATLAB Coder tool. This tool allows you to generate C or C++ code from your MATLAB algorithms and functions, which can then be integrated into other applications.

To use the MATLAB Coder, you will need to have a MATLAB Coder license and access to the code you want to convert. Once you have these, you can follow the steps outlined in the MATLAB documentation to generate the C or C++ code.

As for running the code on a MAC, you can use a C or C++ compiler for MAC to compile the code generated by the MATLAB Coder. You can then use the compiled code in X-Code, which is compatible with Objective-C.

I hope this helps. If you require further assistance, I suggest posting your question on the MATLAB forum or contacting MathWorks support for more specific guidance.

Best of luck with your project!
 

Related to MATLAB Conversion Help (to c or c++)

What is MATLAB Conversion?

MATLAB Conversion is the process of translating MATLAB code into another programming language, such as C or C++. This is typically done to improve the performance or portability of the code.

Why would I need to convert my MATLAB code?

There are a few reasons why you may need to convert your MATLAB code. One common reason is to improve the speed and efficiency of your code, as some other languages may be better suited for certain tasks. Another reason may be to make your code more portable, allowing it to be used on different platforms or integrated with other programs.

Can I convert any MATLAB code to C or C++?

In most cases, yes. However, there are some limitations and differences between MATLAB and other languages that may require manual adjustments or modifications to the code during the conversion process. It is important to carefully review and test the converted code to ensure it functions correctly.

Is there a tool or software to help with MATLAB conversion?

Yes, there are various tools and software available that can assist with MATLAB conversion. These include built-in functions in MATLAB itself, as well as third-party tools and plugins. However, it is still important to understand the conversion process and have a good understanding of both MATLAB and the target language.

Are there any resources available to learn how to convert MATLAB code?

Yes, there are many online tutorials, guides, and forums available to help you learn how to convert MATLAB code. Additionally, many universities and institutions offer courses on MATLAB and its conversion to other languages. It is also helpful to consult with experienced programmers or seek assistance from online communities for specific questions or issues.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
916
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
12
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
3K
  • Introductory Physics Homework Help
Replies
4
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
Back
Top