MATLAB 编程最佳实践 [英] MATLAB programming best practices

查看:23
本文介绍了MATLAB 编程最佳实践的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找有关如何构建大中型 MATLAB 项目的资源,尤其是涉及多个独立模块的项目.如何管理全局配置变量,如何将项目组织到文件夹中,如何管理模块之间的耦合等.

I'm looking for resources on how to structure medium- to large-scale MATLAB projects, especially ones that involve several independent modules. How do I manage global configuration variables, how do I structure the project into folders, how do I manage couplings between modules, etc.

有关于这个主题的某种标准文本吗?似乎大多数 MATLAB 教科书都是由科学家或工程师编写的.我想,我正在寻找的是由软件工程师编写的任何 MATLAB 教科书.:-)

Is there some kind of standard text on this subject? It looks as if most MATLAB textbooks have been written by scientists or engineers. What I'm looking for, I guess, is any MATLAB textbook written by a software engineer. :-)

推荐答案

MATLAB 是大型项目的不寻常选择,并且非常适合于诸如汇编程序、COBOL 或 SQL 之类的任务.如果您仍然选择 MATLAB,那么至少会自动测试代码!各种测试 - 集成测试、单元测试、负载测试!当然还要使用版本控制系统.

MATLAB is an unusual choice for a large-scale projects and is as much suited for such task as assembler, COBOL or SQL. If you still choose MATLAB then at least automatically test the code! All kind of tests - integration tests, unit tests, load tests! And of course use a version control system.

如前所述,MATLAB 并不是为大型项目而创建的,因此关于项目结构、模块、耦合的唯一最佳实践是常识.

As said, MATLAB was not created with large projects in mind therefore the only best practice regarding project structure, modules, coupling is the common sense.

如果您要接管现有的大型 MATLAB 项目,那么我很抱歉,重构将是一场噩梦.如果您打算使用 MATLAB 开始一个新的大型项目,那么您就疯了 - MATLAB 有更好的替代方案,而且在数值性能方面还不错.大项目意味着几乎所有的代码都是业务逻辑,而不是数字,所以看在上帝的份上,MATLAB 是什么?

If you are taking over an existing large MATLAB project then I am sorry with you, refactoring will be nightmare. If you are going to start a new large project with MATLAB then you are crazy - there are much better alternatives to MATLAB that are not that bad regarding numeric performance. Large project implies that almost all code is business logic, not numerics, therefore why for God's sake MATLAB?

大型项目意味着结构良好的组件,这意味着面向对象,这是MATLAB的弱点,因为它牺牲了堆性能不可用程度的数值性能.

Large project implies well structured components, which implies OO, which is the weak point of MATLAB because it sacrifices heap performance for numeric performance to the degree of unusability.

我的经验:

  1. 我在一个价值 50 万美元的 LOC MATLAB 项目中花费了数年时间.
  2. 我已经看到多个大型 MATLAB 项目轻松过渡到 C#.

使用 MATLAB,您仍然需要使用大量 Java 来获得外观漂亮的 GUI,使用 C/C++ MEX 来实现快速的非数字部分,例如导入,也许是 SQL 等.使用带有免费数字库的 Java(或更好的 C#)只有一种语言完全适合您在大型项目中所需的一切.

With MATLAB you still have to use large amounts of Java for decent looking GUI, C/C++ MEX for fast not numeric parts like imports, maybe SQL, etc. With Java (or better C#) with a free numeric library you have only one language which is perfectly suited for everything you need in a large project.

我并不是说 MATLAB 不好 - 它规定了快速原型设计和数值计算!而且 Simulink 没有替代品(但可以从任何地方编译和使用).

I am not saying that MATLAB is bad - it rules for rapid prototyping and numerics! And Simulink has no alternatives (but can be compiled and used from everywhere).

这篇关于MATLAB 编程最佳实践的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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