Advertisement

Matlab Vs C++

Started by October 11, 2005 02:48 AM
5 comments, last by sidhantdash 19 years, 1 month ago
Hi As I am starting to program my Neural Networks, I am confused whether I should use Matlab or C++. I learnt somewhere that Matlab has a NN toolkit, that has a lot of pre-defined routines that one can use. But problem is, I dont know any Matlab, and really dont know if as a novice, I would ever need those functions. But, if it is going to benefit me later, when I go deeper into NNs, then I am ready to put in that extra effort. Do you think I should go in for Matlab, or is C++ good enough? And if its C++, then is Visual C++ any better for NNs, than some no-frills (no GUI, etc) version? thanks
Quote: Original post by sidhantdash
Hi
As I am starting to program my Neural Networks, I am confused whether I should use Matlab or C++. I learnt somewhere that Matlab has a NN toolkit, that has a lot of pre-defined routines that one can use. But problem is, I dont know any Matlab, and really dont know if as a novice, I would ever need those functions.


Look at the documentation first, check any correspondance with what you plan to do, and decide.

Quote:
But, if it is going to benefit me later, when I go deeper into NNs, then I am ready to put in that extra effort. Do you think I should go in for Matlab, or is C++ good enough?


I would say, go with whatever requires the least work (once you know what it is capable of).

Quote:
And if its C++, then is Visual C++ any better for NNs, than some no-frills (no GUI, etc) version? thanks


No, you won't gain anything (aside from IDE ease of use).



Advertisement
First of all, I know MATLAB has a C SDK you can use in your C++ programs.

If you're heavily into NN, you should know your Matlab - simply because NN requires many tweaking and experimenting, and it would be way easier to do that than in C++. However, C++ will force you to understand the basics of NN - which are an important ground for successfully experimenting with them.

Bear in mind that the learning curve of Matlab is very, very low. I have learned Matlab at least 5 times (I keep forgetting it because I don't use it on a regular basis) - it took me about 1 hour every time to understand it in a level that enabled me of programming M scripts. It's a very convenient environment once you get the hang of it.
Dubito, Cogito ergo sum.
It depending a little bit how much you have math. MatLab is great tool for signal prosessing with those cool toolboxis. It best part is actually digital signal analyse. But like doing new cells in neural network i will stick with c++. Just because OOP. Mayby then I use Matlab to analyse signal.
I use Matlab extensively nearly every day I am at work. It is a great tool for prototyping systems across a massive range of problems. It's NOT just good for signal processing... it's good for a huge range of problems. The initial development time for getting your models running (and this is especially true for ANNs) is minimal. Matlab does require a basic knowledge of programming in C, or a 'C-like' language, as the Matlab script language is based around C. If you're a competent C++ programmer, you'll have absolutely no problem programming in Matlab. Trust me, it's very easy to learn. Matlab also provides limited OOP functionality.

Once you've got things going inside Matlab, then you have several options available to you:

(1) You can start from scratch and write it in C++, knowing that the basic design is correct; or,
(2) You can use Matlab's compiler to produce either stand-alone executables or static/dynamic libraries; or,
(3) You can use Matlab's compiler to generate C or C++ code that you can include in your larger project.

If your ANN is to be part of a larger product/project, then you could develop the ANN portion inside Matlab and when you have a working model, package it into a library for linking into your larger C++ project. Once everything is going THEN evaluate your system and look for bottlenecks. If the library is causing you performance issues, THEN you have the opportunity to rewrite it to obtain better performance. Generally though, I've never needed to do this. The sorts of systems I work on suffer greater bottlenecks than the few extra function calls matlab uses in its automatically generated code. Certainly their Compiler 4.0 produces code with good performance.

If you're going to do any sort of scientific or numerical computing/modelling (such as developing ANN models) then I highly recommend Matlab.

Cheers,

Timkin
I'm currently taking an ANN course, and we exclusively use MatLab. Initially I was stubborn and thought I would do everything in C, but I quickly learned the error in my ways!

There are two main advantages to MatLab in my mind: (1) It is interpreted, so you just make a quick change, hit a single button, and everything updates immediately, and (2) You can easily draw and manipulate graphs. Like was mentioned above, a lot of learning ANNs is getting a conceptual understanding of what will happen if you tweak one parameter of a differential equation or what may happen if you change an input or training pattern. In MatLab, you can very quickly tweak these parameters and see the changes immediately.

We don't use the ANN toolkit you mentioned, and frankly you probably don't want to use it unless you have a good understanding of how its functions work. So for the "better understanding" reason above for using C, you can get that same understanding in MatLab by coding the ANNs by hand rather than relying on a package. (It really isn't that many lines of code for the basic ANNs ;-))
h20, member of WFG 0 A.D.
Advertisement
Thanks everyone.
After listening what was said I checked out a Matlab manual, and found it to be pretty easy, part of the reason for this being my familiarity with C++.
And its real good to know that I dont have to use any of the toolboxes. I am a beginner in NNs, and must code my own programs/algorithms to get a good grasp of things. Additionally, I am majoring in Math. And has already been said in one of the replies, Matlab is extensively used in modelling, etc, and it will be only be good if I get to know Matlab well.
thanks again guys......

This topic is closed to new replies.

Advertisement