简体   繁体   English

代码从matlab到c ++

[英]code from matlab into c++

Is there any best approach or template to follow, while doing this? 这样做有没有最好的方法或模板? I mean two things in particular, because for me it is problematic to imagine how it would go in c++: 我的意思是两件事,特别是对我来说,想象一下它在c ++中会有什么问题:

  • expanding arrays on go, where they are expanded during program and i dont know whethere the final size will be eg 10 or 100000. 在程序中扩展阵列,在程序期间扩展阵列,我不知道最终大小将是10或100000。
  • plots. 地块。 I have never done any plot in c++ as I always have been doing it in matlab when necessary. 我从来没有在c ++中做任何绘图,因为我一直在matlab中做必要的时候。

So what templates or rules should I follow, and how could I cope with those two things? 那么我应该遵循哪些模板或规则,我怎样才能应对这两件事? I found that eigen library would be useful for matrices (dynamically expanding also?), but as I am not sure, want to ask first to be sure of a right approach. 我发现特征库对矩阵很有用(也可以动态扩展?),但是我不确定,首先想要确定一个正确的方法。 Nothing i know about plots. 我对剧情一无所知。

Please add some link for me to learn from, if useful. 如果有用,请添加一些链接供我学习。 Thanks! 谢谢!

  • expanding arrays on go, where they are expanded during program and i dont know whethere the final size will be eg 10 or 100000. 在程序中扩展阵列,在程序期间扩展阵列,我不知道最终大小将是10或100000。

The solution to this is simple: look up std::vector (or std::deque ) both provide this behaviour. 对此的解决方案很简单:查找std::vector (或std::deque )都提供此行为。 (With "subtle" differences between a deque and a vector). (在deque和vector之间存在“微妙的”差异)。

  • plots. 地块。 I have never done any plot in c++ as I always have been doing it in matlab when necessary. 我从来没有在c ++中做任何绘图,因为我一直在matlab中做必要的时候。

For this you'll have to search for a library that can do this, first you'll have to look into a graphical window library such as Qt. 为此,您必须搜索可以执行此操作的库,首先您必须查看Qt等图形窗口库。 And then you'll have to look up some library that can plot data in a graph form. 然后你将不得不查找一些可以以图表形式绘制数据的库。
Though for this matlab will probably always be the "easier/better" choice; 虽然对于这个matlab可能总是“更容易/更好”的选择; C++ has nothing to help you with this. C ++没有什么可以帮助你的。

Also remember: first learn the language, then learn libraries! 还记得:先学习语言,然后学习图书馆!

对于使用QT绘图, QWT基本上是您所需要的,因为它提供了可能需要的所有非平凡类型的图表。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM