Matlab的codeR VS手工编码? [英] Matlab Coder vs hand coding?

查看:100
本文介绍了Matlab的codeR VS手工编码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一些背景的人在未来阅读本(如果它不是锁定)。我倾向于做一个高级语言首先要明白这个问题我的节目。涵盖所有可能的角落案件后,我着手翻译code到C ++(或C)。

Some background for people reading this in the future (in case it's not locked). I tend to do my programming in a high level language to understand the problem first. After covering all possible corner cases I proceed to translating the code to C++ (or C).

大部分code我写中有数学等MATLAB是我使用(对我的选择是Python)的语言。无论如何,我再用手翻译code从MATLAB到C ++。

Most of the code I write has maths in it and so MATLAB is the language I use (the alternative for me is Python). Anyway, I then translate the code from MATLAB to C++ by hand.

有谁知道是否有使用MATLAB codeR什么优势/劣势?这是一个新的产品,非常昂贵,但除了它翻译节省时间还有没有其他好处?

Does anyone know if there is any advantage/disadvantage in using MATLAB Coder? It's a new product and very expensive but apart from the time it saves in translation is there any other benefit?

推荐答案

免责声明

这是基于我的expirience一个特定的项目非常固执己见职位。我没有使用最新版本的codeR,但我确实有与同等产品(嵌入codeR)的expirience为MATLAB code转换成C ++里包含前者实时车间的一部分产品。这些意见应该仍然适用。你的情况可能会有所不同。

This is a very opinionated post based on my expirience for one particular project. I have not used the latest version of the coder, but I do have expirience with the equivalent product (embedded coder) for converting matlab code to C++ that was included as part of the former Real Time Workshop product. These comments should still apply. Your mileage may vary.

早期的待遇。

在我的情况,使用了嵌入式codeR使配合到一个更大的音频应用程序的一部分的处理块。处理块有实时处理样品缓冲器的恒定流的作业。我在MATLAB所作的原始算法和转换工具使得相当简单的早期原型转换到的东西,可以编译为本地code和在实时应用中使用。这也是很好的假设,该转换后的code的相同功能数值与原始未经在转换过程中的人为错误的可能性(假设Mahworks工程师超人能力)。

In my situation, the embedded coder was used to make a processing block that fit into part of a larger audio application. The processing block had the job of processing a constant stream of sample buffers in real time. I made the original algorithm in matlab, and the conversion tool made it fairly simple to convert an early prototype into something that could be compiled to native code and used in a real time application. It was also nice to assume that the converted code was functioning numerically identically to the original without possibility of human error in the conversion process (assuming superhuman abilities of Mahworks engineers).

的好处这个非常早期的原型阶段结束后...

问题1:浪费时间的接口

Problem 1: Wasting time interfacing

由于算法的复杂性的增长,我开始担心如何code MATLAB的接口功能,使转换后,它会很容易与C ++框架相连接(我想监视更多实时内部状态)。这最终开始用尽可能多的时间与实际算法本身的发展,从而击败使用这种工具的目的。我可以分解算法成小块,然后用C ++粘在一起,但后来我松散有他完整的算法直接Matlab的只是比较的能力。

As the algorithm grew in complexity, i started worrying more and more about how to code the matlab interface to the function so that after conversion, it would be easy to interface with the C++ framework (I wanted to monitor the internal states in real time). This eventually started using as much time as the actual algorithm development itself, thus defeating the purpose of using such a tool. I could have broken down the algorithm into smaller chunks and then glued them together using C++, but then I'd loose the ability to have a direct Matlab-only comparison of he complete algorithm.

问题2:并非所有的功能都支持或完全支持

Problem 2: Not all functions are supported or supported fully

在codeR支持的子MATLAB语言。在某些情况下,所支持的功能在某些方面受到限制。例如,在我正在工作的应用程序,我希望能够修改实时的滤波器的特性。我无法用标准的Matlab的过滤器原型的功能,因为code生成工具,不能够把可变参数的过滤器原型的函数调用。最后我花时间与DSP开发的书我自己的实现,虽然我们有一个信号处理工具箱许可证。

The coder supports a subset of the Matlab language. In some cases, supported functions are limited in some way. For example, in the application that I was working on, I wanted to be able to modify the characteristics of a filter in real time. I could not use the standard Matlab filter prototyping functions, because the code generation tool would not allow calls to the filter prototyping function with variable arguments. I ended up spending time with a DSP book developing my own implementation, even though we have a signal processing toolbox license.

问题3:自动生成code是低效的。

Problem 3: Automatically generated code was inefficient

我很沮丧的界面问题和codeD算法用手在C ++中。我的应用程序,有一个在赞成手写code在转换code的75%的性能提升。性能差异将取决于你的应用程序中,所使用的转换工具的可能的版本,和你的分析器的喜好有很大的差别。转换工具本身是一个复杂的产品,有许多设置学习。试图找出如何调整设置和MATLAB code,以提高性能,使用了更多的可能被花在手工编码的时间。

I got frustrated with the interface issues and coded the algorithm by hand in C++. For my application, there was a 75% performance boost in the favour of the hand written code over the converted code. Performance differences will be very different depending on your application, probably the version of the conversion tool used, and your fondness of your profiler. The conversion tool itself is a complex product that has many settings to learn. Trying to work out how to tweak settings and the matlab code to improve performance uses more time that could be spent hand coding.

我还没有使用的转换工具,因为...

我现在preFER更测试 - 的帮助的办法。我code在Matlab原型和调整,直到我确信,它的行为,因为我想这一点。那么我认为C ++和重新code的方式,更自然该语言的算法。然后我做了我的C ++ code接口一个MEX文件,这样我就可以测试对我的信任的MATLAB等价的。对于这个问题的空间,我的工作中,这是一种更有效的(人与机器)的方式得到的东西做的。

I now prefer a more test-assisted approach. I code a prototype in Matlab and tweak until I am sure that it behaves as I want it too. I then think in C++ and recode the algorithm in a way that is more natural to that language. I then make a mex file that interfaces with my C++ code so I can test it against my trusted matlab equivalent. For the problem space that I work in, this is a much more efficient (human and machine) way to get stuff done.

在最后,这是一个用户的只是意见。也许(如您的原始信息的评论中suggesred),你应该报名参加试用,看看你一起怎么弄。但是,如果你是一个有点C ++的忍者,通过建立MEX文件测试并不需要一个附加产品昂贵的许可证,它将使你成为一个更好的开发者。

In conclusion, this is just the opinion of one user. Perhaps (as suggesred in a comment on your original post) you should sign up for the trial to see how you get along. However, if you are a bit of a C++ ninja, testing by building mex files does not require an expensive license for an add-on product and it will make you a better developer.

这篇关于Matlab的codeR VS手工编码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆