Matlab to C or C++





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







21















I am working on an image processing project using Matlab. We should run our program (intended to be an application) on a cell phone.We were then asked to convert our code into C or C++ language so we get a feel of how long it would take for execution and then choose a platform. So far we didn't figure out how to do this conversion.. Any ideas of what to do to convert Matlab to C or C++??










share|improve this question




















  • 5





    This question is unanswerable. The only way to do this is to rewrite your specific algorithms in C or C++.

    – Chinmay Kanchi
    Nov 12 '10 at 16:30






  • 1





    @ChinmayKanchi No, it is certainly answerable. You can automatically convert some Matlab programs into C or C++ using Matlab Coder.

    – Anderson Green
    Aug 7 '16 at 19:52


















21















I am working on an image processing project using Matlab. We should run our program (intended to be an application) on a cell phone.We were then asked to convert our code into C or C++ language so we get a feel of how long it would take for execution and then choose a platform. So far we didn't figure out how to do this conversion.. Any ideas of what to do to convert Matlab to C or C++??










share|improve this question




















  • 5





    This question is unanswerable. The only way to do this is to rewrite your specific algorithms in C or C++.

    – Chinmay Kanchi
    Nov 12 '10 at 16:30






  • 1





    @ChinmayKanchi No, it is certainly answerable. You can automatically convert some Matlab programs into C or C++ using Matlab Coder.

    – Anderson Green
    Aug 7 '16 at 19:52














21












21








21


4






I am working on an image processing project using Matlab. We should run our program (intended to be an application) on a cell phone.We were then asked to convert our code into C or C++ language so we get a feel of how long it would take for execution and then choose a platform. So far we didn't figure out how to do this conversion.. Any ideas of what to do to convert Matlab to C or C++??










share|improve this question
















I am working on an image processing project using Matlab. We should run our program (intended to be an application) on a cell phone.We were then asked to convert our code into C or C++ language so we get a feel of how long it would take for execution and then choose a platform. So far we didn't figure out how to do this conversion.. Any ideas of what to do to convert Matlab to C or C++??







c++ c matlab






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 26 '10 at 2:56









Stuart Golodetz

16.8k23776




16.8k23776










asked Nov 12 '10 at 16:24









emmaemma

112113




112113








  • 5





    This question is unanswerable. The only way to do this is to rewrite your specific algorithms in C or C++.

    – Chinmay Kanchi
    Nov 12 '10 at 16:30






  • 1





    @ChinmayKanchi No, it is certainly answerable. You can automatically convert some Matlab programs into C or C++ using Matlab Coder.

    – Anderson Green
    Aug 7 '16 at 19:52














  • 5





    This question is unanswerable. The only way to do this is to rewrite your specific algorithms in C or C++.

    – Chinmay Kanchi
    Nov 12 '10 at 16:30






  • 1





    @ChinmayKanchi No, it is certainly answerable. You can automatically convert some Matlab programs into C or C++ using Matlab Coder.

    – Anderson Green
    Aug 7 '16 at 19:52








5




5





This question is unanswerable. The only way to do this is to rewrite your specific algorithms in C or C++.

– Chinmay Kanchi
Nov 12 '10 at 16:30





This question is unanswerable. The only way to do this is to rewrite your specific algorithms in C or C++.

– Chinmay Kanchi
Nov 12 '10 at 16:30




1




1





@ChinmayKanchi No, it is certainly answerable. You can automatically convert some Matlab programs into C or C++ using Matlab Coder.

– Anderson Green
Aug 7 '16 at 19:52





@ChinmayKanchi No, it is certainly answerable. You can automatically convert some Matlab programs into C or C++ using Matlab Coder.

– Anderson Green
Aug 7 '16 at 19:52












7 Answers
7






active

oldest

votes


















12














Matlab can gererate C code for you.



See:
http://www.mathworks.com/products/featured/embeddedmatlab/



The generated code does however depend on matlab libraries. So you probably can't use it for a cell phone. But it might save you some time anyways.






share|improve this answer
























  • @learnvst unfortunately that link is broken.

    – moooeeeep
    Jul 10 '12 at 11:53











  • Follow the link here for alphabetical or categorical lists mathworks.co.uk/help/toolbox/eml/ug/bsud5f4.html

    – learnvst
    Jul 10 '12 at 12:12



















12














The first thing you need to realise is that porting code from one language to another (especially languages as different as Matlab and C++) is generally non-trivial and time-consuming. You need to know both languages well, and you need to have similar facilities available in both. In the case of Matlab and C++, Matlab gives you a lot of stuff that you just won't have available in C++ without using libraries. So the first thing to do is identify which libraries you're going to need to use in C++. (You can write some of the stuff yourself, but you'll be there a long time if you write all of it yourself.)



If you're doing image processing, I highly recommend looking into something like ITK at http://www.itk.org -- I've written my image processing software twice in C++, once without ITK (coding everything myself) and once with, and the version that used ITK was finished faster, performed better and was ten times more fun to work on. FWIW.






share|improve this answer
























  • Incidentally, ITK might look as if it's just for segmentation and registration, but it's actually pretty good for general image processing as well.

    – Stuart Golodetz
    Nov 12 '10 at 16:34



















6














I also used the MATLAB Coder to convert some functions consisting of a few hundred lines of MATLAB into C. This included using MATLAB's eigenvalue solver and matrix inversion functions.



Although Coder was able to produce C code (which theoretically was identical), it was very convoluted, bloated, impossible to decipher, and appeared to be extremely inefficient. It literally created about 10x as many lines of code as it should have needed. I ended up converting it all by hand so that I would actually be able to comprehend the C code later and make further changes/updates. This task however, can be very tedious/dangerous, as the array indexing in Matlab is 1-based and in C it's 0-based. You're likely to add bugs into the code, as I experienced. you'll also have to convert any vector/matrix arithmetic into loops that handle scalars (or use some type of C matrix algebra package)






share|improve this answer































    5














    The MathWorks provides a product called MATLAB Coder that claims to generate "readable and portable C and C++ code from MATLAB® code". I haven't tried it myself, so I can't comment on how well it accomplishes these goals.



    With regard to the Image Processing Toolbox, this list (presumably for R2016b) shows which functions have been enabled for code generation and any limitations they may have.






    share|improve this answer

































      2














      Matlab has a tool called "Matlab Coder" which can convert your matlab file to C code or mex file. My code is relatively simple so it works fine. Speed up gain is about 10 times faster. This saves me time coding a few hundreds lines. Hope it's helpful for you too



      Quick Start Guide for MATLAB Coder Confirmation



      The links describe the process of converting your code in 3 major steps:




      • First you need to make a few simplifications in your present code so that it would be simple enough for the Coder to translate.


      • Second, you will use the tool to generate a mex file and test if everything is actually working.


      • Finally you would change some setting and generate the C code. In my case, the C code has about 700 lines including all the original matlab code (about 150 lines) as comments. I think it's quite readable and could be improve upon. However, I already get a 10 times speed up gain from the mex file anyway. So this is definitely a good thing.



      We can't not be sure that this will work in all case but it's definitely worth trying.






      share|improve this answer































        1














        I remember there is a tool to export m-files as c(++)-files. But I could never get that running. You need to add some obscure MATLAB-headers in the c/c++code, ... And I think it is also not recommended.



        If you have running MATLAB-code, it shouldn't take too much effort to do the conversion "by hand". I have been working on several project where MATLAB was used and it was never consider to use any tools to convert the code to C/C++. It was always done "by hand".



        I believe to have been the only one who ever investigate into using a tool.






        share|improve this answer































          0














          Well there is not straight conversion from matlab to c/c++ You will need to understand the language and the differences between matlab and c/c++ and then start coding it in c/c++. Code a little test a little until it works.






          share|improve this answer
























            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f4166755%2fmatlab-to-c-or-c%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            7 Answers
            7






            active

            oldest

            votes








            7 Answers
            7






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            12














            Matlab can gererate C code for you.



            See:
            http://www.mathworks.com/products/featured/embeddedmatlab/



            The generated code does however depend on matlab libraries. So you probably can't use it for a cell phone. But it might save you some time anyways.






            share|improve this answer
























            • @learnvst unfortunately that link is broken.

              – moooeeeep
              Jul 10 '12 at 11:53











            • Follow the link here for alphabetical or categorical lists mathworks.co.uk/help/toolbox/eml/ug/bsud5f4.html

              – learnvst
              Jul 10 '12 at 12:12
















            12














            Matlab can gererate C code for you.



            See:
            http://www.mathworks.com/products/featured/embeddedmatlab/



            The generated code does however depend on matlab libraries. So you probably can't use it for a cell phone. But it might save you some time anyways.






            share|improve this answer
























            • @learnvst unfortunately that link is broken.

              – moooeeeep
              Jul 10 '12 at 11:53











            • Follow the link here for alphabetical or categorical lists mathworks.co.uk/help/toolbox/eml/ug/bsud5f4.html

              – learnvst
              Jul 10 '12 at 12:12














            12












            12








            12







            Matlab can gererate C code for you.



            See:
            http://www.mathworks.com/products/featured/embeddedmatlab/



            The generated code does however depend on matlab libraries. So you probably can't use it for a cell phone. But it might save you some time anyways.






            share|improve this answer













            Matlab can gererate C code for you.



            See:
            http://www.mathworks.com/products/featured/embeddedmatlab/



            The generated code does however depend on matlab libraries. So you probably can't use it for a cell phone. But it might save you some time anyways.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Nov 12 '10 at 16:31









            StefanStefan

            2,38712133




            2,38712133













            • @learnvst unfortunately that link is broken.

              – moooeeeep
              Jul 10 '12 at 11:53











            • Follow the link here for alphabetical or categorical lists mathworks.co.uk/help/toolbox/eml/ug/bsud5f4.html

              – learnvst
              Jul 10 '12 at 12:12



















            • @learnvst unfortunately that link is broken.

              – moooeeeep
              Jul 10 '12 at 11:53











            • Follow the link here for alphabetical or categorical lists mathworks.co.uk/help/toolbox/eml/ug/bsud5f4.html

              – learnvst
              Jul 10 '12 at 12:12

















            @learnvst unfortunately that link is broken.

            – moooeeeep
            Jul 10 '12 at 11:53





            @learnvst unfortunately that link is broken.

            – moooeeeep
            Jul 10 '12 at 11:53













            Follow the link here for alphabetical or categorical lists mathworks.co.uk/help/toolbox/eml/ug/bsud5f4.html

            – learnvst
            Jul 10 '12 at 12:12





            Follow the link here for alphabetical or categorical lists mathworks.co.uk/help/toolbox/eml/ug/bsud5f4.html

            – learnvst
            Jul 10 '12 at 12:12













            12














            The first thing you need to realise is that porting code from one language to another (especially languages as different as Matlab and C++) is generally non-trivial and time-consuming. You need to know both languages well, and you need to have similar facilities available in both. In the case of Matlab and C++, Matlab gives you a lot of stuff that you just won't have available in C++ without using libraries. So the first thing to do is identify which libraries you're going to need to use in C++. (You can write some of the stuff yourself, but you'll be there a long time if you write all of it yourself.)



            If you're doing image processing, I highly recommend looking into something like ITK at http://www.itk.org -- I've written my image processing software twice in C++, once without ITK (coding everything myself) and once with, and the version that used ITK was finished faster, performed better and was ten times more fun to work on. FWIW.






            share|improve this answer
























            • Incidentally, ITK might look as if it's just for segmentation and registration, but it's actually pretty good for general image processing as well.

              – Stuart Golodetz
              Nov 12 '10 at 16:34
















            12














            The first thing you need to realise is that porting code from one language to another (especially languages as different as Matlab and C++) is generally non-trivial and time-consuming. You need to know both languages well, and you need to have similar facilities available in both. In the case of Matlab and C++, Matlab gives you a lot of stuff that you just won't have available in C++ without using libraries. So the first thing to do is identify which libraries you're going to need to use in C++. (You can write some of the stuff yourself, but you'll be there a long time if you write all of it yourself.)



            If you're doing image processing, I highly recommend looking into something like ITK at http://www.itk.org -- I've written my image processing software twice in C++, once without ITK (coding everything myself) and once with, and the version that used ITK was finished faster, performed better and was ten times more fun to work on. FWIW.






            share|improve this answer
























            • Incidentally, ITK might look as if it's just for segmentation and registration, but it's actually pretty good for general image processing as well.

              – Stuart Golodetz
              Nov 12 '10 at 16:34














            12












            12








            12







            The first thing you need to realise is that porting code from one language to another (especially languages as different as Matlab and C++) is generally non-trivial and time-consuming. You need to know both languages well, and you need to have similar facilities available in both. In the case of Matlab and C++, Matlab gives you a lot of stuff that you just won't have available in C++ without using libraries. So the first thing to do is identify which libraries you're going to need to use in C++. (You can write some of the stuff yourself, but you'll be there a long time if you write all of it yourself.)



            If you're doing image processing, I highly recommend looking into something like ITK at http://www.itk.org -- I've written my image processing software twice in C++, once without ITK (coding everything myself) and once with, and the version that used ITK was finished faster, performed better and was ten times more fun to work on. FWIW.






            share|improve this answer













            The first thing you need to realise is that porting code from one language to another (especially languages as different as Matlab and C++) is generally non-trivial and time-consuming. You need to know both languages well, and you need to have similar facilities available in both. In the case of Matlab and C++, Matlab gives you a lot of stuff that you just won't have available in C++ without using libraries. So the first thing to do is identify which libraries you're going to need to use in C++. (You can write some of the stuff yourself, but you'll be there a long time if you write all of it yourself.)



            If you're doing image processing, I highly recommend looking into something like ITK at http://www.itk.org -- I've written my image processing software twice in C++, once without ITK (coding everything myself) and once with, and the version that used ITK was finished faster, performed better and was ten times more fun to work on. FWIW.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Nov 12 '10 at 16:32









            Stuart GolodetzStuart Golodetz

            16.8k23776




            16.8k23776













            • Incidentally, ITK might look as if it's just for segmentation and registration, but it's actually pretty good for general image processing as well.

              – Stuart Golodetz
              Nov 12 '10 at 16:34



















            • Incidentally, ITK might look as if it's just for segmentation and registration, but it's actually pretty good for general image processing as well.

              – Stuart Golodetz
              Nov 12 '10 at 16:34

















            Incidentally, ITK might look as if it's just for segmentation and registration, but it's actually pretty good for general image processing as well.

            – Stuart Golodetz
            Nov 12 '10 at 16:34





            Incidentally, ITK might look as if it's just for segmentation and registration, but it's actually pretty good for general image processing as well.

            – Stuart Golodetz
            Nov 12 '10 at 16:34











            6














            I also used the MATLAB Coder to convert some functions consisting of a few hundred lines of MATLAB into C. This included using MATLAB's eigenvalue solver and matrix inversion functions.



            Although Coder was able to produce C code (which theoretically was identical), it was very convoluted, bloated, impossible to decipher, and appeared to be extremely inefficient. It literally created about 10x as many lines of code as it should have needed. I ended up converting it all by hand so that I would actually be able to comprehend the C code later and make further changes/updates. This task however, can be very tedious/dangerous, as the array indexing in Matlab is 1-based and in C it's 0-based. You're likely to add bugs into the code, as I experienced. you'll also have to convert any vector/matrix arithmetic into loops that handle scalars (or use some type of C matrix algebra package)






            share|improve this answer




























              6














              I also used the MATLAB Coder to convert some functions consisting of a few hundred lines of MATLAB into C. This included using MATLAB's eigenvalue solver and matrix inversion functions.



              Although Coder was able to produce C code (which theoretically was identical), it was very convoluted, bloated, impossible to decipher, and appeared to be extremely inefficient. It literally created about 10x as many lines of code as it should have needed. I ended up converting it all by hand so that I would actually be able to comprehend the C code later and make further changes/updates. This task however, can be very tedious/dangerous, as the array indexing in Matlab is 1-based and in C it's 0-based. You're likely to add bugs into the code, as I experienced. you'll also have to convert any vector/matrix arithmetic into loops that handle scalars (or use some type of C matrix algebra package)






              share|improve this answer


























                6












                6








                6







                I also used the MATLAB Coder to convert some functions consisting of a few hundred lines of MATLAB into C. This included using MATLAB's eigenvalue solver and matrix inversion functions.



                Although Coder was able to produce C code (which theoretically was identical), it was very convoluted, bloated, impossible to decipher, and appeared to be extremely inefficient. It literally created about 10x as many lines of code as it should have needed. I ended up converting it all by hand so that I would actually be able to comprehend the C code later and make further changes/updates. This task however, can be very tedious/dangerous, as the array indexing in Matlab is 1-based and in C it's 0-based. You're likely to add bugs into the code, as I experienced. you'll also have to convert any vector/matrix arithmetic into loops that handle scalars (or use some type of C matrix algebra package)






                share|improve this answer













                I also used the MATLAB Coder to convert some functions consisting of a few hundred lines of MATLAB into C. This included using MATLAB's eigenvalue solver and matrix inversion functions.



                Although Coder was able to produce C code (which theoretically was identical), it was very convoluted, bloated, impossible to decipher, and appeared to be extremely inefficient. It literally created about 10x as many lines of code as it should have needed. I ended up converting it all by hand so that I would actually be able to comprehend the C code later and make further changes/updates. This task however, can be very tedious/dangerous, as the array indexing in Matlab is 1-based and in C it's 0-based. You're likely to add bugs into the code, as I experienced. you'll also have to convert any vector/matrix arithmetic into loops that handle scalars (or use some type of C matrix algebra package)







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Mar 13 '13 at 4:18









                MasterHDMasterHD

                1,2182130




                1,2182130























                    5














                    The MathWorks provides a product called MATLAB Coder that claims to generate "readable and portable C and C++ code from MATLAB® code". I haven't tried it myself, so I can't comment on how well it accomplishes these goals.



                    With regard to the Image Processing Toolbox, this list (presumably for R2016b) shows which functions have been enabled for code generation and any limitations they may have.






                    share|improve this answer






























                      5














                      The MathWorks provides a product called MATLAB Coder that claims to generate "readable and portable C and C++ code from MATLAB® code". I haven't tried it myself, so I can't comment on how well it accomplishes these goals.



                      With regard to the Image Processing Toolbox, this list (presumably for R2016b) shows which functions have been enabled for code generation and any limitations they may have.






                      share|improve this answer




























                        5












                        5








                        5







                        The MathWorks provides a product called MATLAB Coder that claims to generate "readable and portable C and C++ code from MATLAB® code". I haven't tried it myself, so I can't comment on how well it accomplishes these goals.



                        With regard to the Image Processing Toolbox, this list (presumably for R2016b) shows which functions have been enabled for code generation and any limitations they may have.






                        share|improve this answer















                        The MathWorks provides a product called MATLAB Coder that claims to generate "readable and portable C and C++ code from MATLAB® code". I haven't tried it myself, so I can't comment on how well it accomplishes these goals.



                        With regard to the Image Processing Toolbox, this list (presumably for R2016b) shows which functions have been enabled for code generation and any limitations they may have.







                        share|improve this answer














                        share|improve this answer



                        share|improve this answer








                        edited Mar 8 '17 at 18:09

























                        answered May 6 '11 at 15:31









                        gnovicegnovice

                        117k13234337




                        117k13234337























                            2














                            Matlab has a tool called "Matlab Coder" which can convert your matlab file to C code or mex file. My code is relatively simple so it works fine. Speed up gain is about 10 times faster. This saves me time coding a few hundreds lines. Hope it's helpful for you too



                            Quick Start Guide for MATLAB Coder Confirmation



                            The links describe the process of converting your code in 3 major steps:




                            • First you need to make a few simplifications in your present code so that it would be simple enough for the Coder to translate.


                            • Second, you will use the tool to generate a mex file and test if everything is actually working.


                            • Finally you would change some setting and generate the C code. In my case, the C code has about 700 lines including all the original matlab code (about 150 lines) as comments. I think it's quite readable and could be improve upon. However, I already get a 10 times speed up gain from the mex file anyway. So this is definitely a good thing.



                            We can't not be sure that this will work in all case but it's definitely worth trying.






                            share|improve this answer




























                              2














                              Matlab has a tool called "Matlab Coder" which can convert your matlab file to C code or mex file. My code is relatively simple so it works fine. Speed up gain is about 10 times faster. This saves me time coding a few hundreds lines. Hope it's helpful for you too



                              Quick Start Guide for MATLAB Coder Confirmation



                              The links describe the process of converting your code in 3 major steps:




                              • First you need to make a few simplifications in your present code so that it would be simple enough for the Coder to translate.


                              • Second, you will use the tool to generate a mex file and test if everything is actually working.


                              • Finally you would change some setting and generate the C code. In my case, the C code has about 700 lines including all the original matlab code (about 150 lines) as comments. I think it's quite readable and could be improve upon. However, I already get a 10 times speed up gain from the mex file anyway. So this is definitely a good thing.



                              We can't not be sure that this will work in all case but it's definitely worth trying.






                              share|improve this answer


























                                2












                                2








                                2







                                Matlab has a tool called "Matlab Coder" which can convert your matlab file to C code or mex file. My code is relatively simple so it works fine. Speed up gain is about 10 times faster. This saves me time coding a few hundreds lines. Hope it's helpful for you too



                                Quick Start Guide for MATLAB Coder Confirmation



                                The links describe the process of converting your code in 3 major steps:




                                • First you need to make a few simplifications in your present code so that it would be simple enough for the Coder to translate.


                                • Second, you will use the tool to generate a mex file and test if everything is actually working.


                                • Finally you would change some setting and generate the C code. In my case, the C code has about 700 lines including all the original matlab code (about 150 lines) as comments. I think it's quite readable and could be improve upon. However, I already get a 10 times speed up gain from the mex file anyway. So this is definitely a good thing.



                                We can't not be sure that this will work in all case but it's definitely worth trying.






                                share|improve this answer













                                Matlab has a tool called "Matlab Coder" which can convert your matlab file to C code or mex file. My code is relatively simple so it works fine. Speed up gain is about 10 times faster. This saves me time coding a few hundreds lines. Hope it's helpful for you too



                                Quick Start Guide for MATLAB Coder Confirmation



                                The links describe the process of converting your code in 3 major steps:




                                • First you need to make a few simplifications in your present code so that it would be simple enough for the Coder to translate.


                                • Second, you will use the tool to generate a mex file and test if everything is actually working.


                                • Finally you would change some setting and generate the C code. In my case, the C code has about 700 lines including all the original matlab code (about 150 lines) as comments. I think it's quite readable and could be improve upon. However, I already get a 10 times speed up gain from the mex file anyway. So this is definitely a good thing.



                                We can't not be sure that this will work in all case but it's definitely worth trying.







                                share|improve this answer












                                share|improve this answer



                                share|improve this answer










                                answered Mar 13 '14 at 6:03









                                BlueSkyBlueSky

                                15817




                                15817























                                    1














                                    I remember there is a tool to export m-files as c(++)-files. But I could never get that running. You need to add some obscure MATLAB-headers in the c/c++code, ... And I think it is also not recommended.



                                    If you have running MATLAB-code, it shouldn't take too much effort to do the conversion "by hand". I have been working on several project where MATLAB was used and it was never consider to use any tools to convert the code to C/C++. It was always done "by hand".



                                    I believe to have been the only one who ever investigate into using a tool.






                                    share|improve this answer




























                                      1














                                      I remember there is a tool to export m-files as c(++)-files. But I could never get that running. You need to add some obscure MATLAB-headers in the c/c++code, ... And I think it is also not recommended.



                                      If you have running MATLAB-code, it shouldn't take too much effort to do the conversion "by hand". I have been working on several project where MATLAB was used and it was never consider to use any tools to convert the code to C/C++. It was always done "by hand".



                                      I believe to have been the only one who ever investigate into using a tool.






                                      share|improve this answer


























                                        1












                                        1








                                        1







                                        I remember there is a tool to export m-files as c(++)-files. But I could never get that running. You need to add some obscure MATLAB-headers in the c/c++code, ... And I think it is also not recommended.



                                        If you have running MATLAB-code, it shouldn't take too much effort to do the conversion "by hand". I have been working on several project where MATLAB was used and it was never consider to use any tools to convert the code to C/C++. It was always done "by hand".



                                        I believe to have been the only one who ever investigate into using a tool.






                                        share|improve this answer













                                        I remember there is a tool to export m-files as c(++)-files. But I could never get that running. You need to add some obscure MATLAB-headers in the c/c++code, ... And I think it is also not recommended.



                                        If you have running MATLAB-code, it shouldn't take too much effort to do the conversion "by hand". I have been working on several project where MATLAB was used and it was never consider to use any tools to convert the code to C/C++. It was always done "by hand".



                                        I believe to have been the only one who ever investigate into using a tool.







                                        share|improve this answer












                                        share|improve this answer



                                        share|improve this answer










                                        answered Nov 12 '10 at 16:34









                                        AudioDroidAudioDroid

                                        1,49921429




                                        1,49921429























                                            0














                                            Well there is not straight conversion from matlab to c/c++ You will need to understand the language and the differences between matlab and c/c++ and then start coding it in c/c++. Code a little test a little until it works.






                                            share|improve this answer




























                                              0














                                              Well there is not straight conversion from matlab to c/c++ You will need to understand the language and the differences between matlab and c/c++ and then start coding it in c/c++. Code a little test a little until it works.






                                              share|improve this answer


























                                                0












                                                0








                                                0







                                                Well there is not straight conversion from matlab to c/c++ You will need to understand the language and the differences between matlab and c/c++ and then start coding it in c/c++. Code a little test a little until it works.






                                                share|improve this answer













                                                Well there is not straight conversion from matlab to c/c++ You will need to understand the language and the differences between matlab and c/c++ and then start coding it in c/c++. Code a little test a little until it works.







                                                share|improve this answer












                                                share|improve this answer



                                                share|improve this answer










                                                answered Nov 12 '10 at 16:27









                                                prolink007prolink007

                                                21.9k18100162




                                                21.9k18100162






























                                                    draft saved

                                                    draft discarded




















































                                                    Thanks for contributing an answer to Stack Overflow!


                                                    • Please be sure to answer the question. Provide details and share your research!

                                                    But avoid



                                                    • Asking for help, clarification, or responding to other answers.

                                                    • Making statements based on opinion; back them up with references or personal experience.


                                                    To learn more, see our tips on writing great answers.




                                                    draft saved


                                                    draft discarded














                                                    StackExchange.ready(
                                                    function () {
                                                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f4166755%2fmatlab-to-c-or-c%23new-answer', 'question_page');
                                                    }
                                                    );

                                                    Post as a guest















                                                    Required, but never shown





















































                                                    Required, but never shown














                                                    Required, but never shown












                                                    Required, but never shown







                                                    Required, but never shown

































                                                    Required, but never shown














                                                    Required, but never shown












                                                    Required, but never shown







                                                    Required, but never shown







                                                    Popular posts from this blog

                                                    "Incorrect syntax near the keyword 'ON'. (on update cascade, on delete cascade,)

                                                    Alcedinidae

                                                    RAC Tourist Trophy