绘制和显示数组的简单方法?
第一篇文章在这里。在 Visual Studio 2008 中使用 C。如果需要,可以使用 VS 2005。
- 如何像在电子表格中一样显示数组中的数值数据?
- 如何在数组中绘制数值数据?
这些看似简单的问题。但我找不到解决方案。到目前为止,我会将数据打印到文件中,导入 Excel 并查看/绘图。然而,这段代码有太多的数组——所以打印/导入/绘图很累。 一些限制。
- 我不想编写 20 多行代码来完成上述操作。 MATFOR 或数组可视化工具让您可以通过一行函数调用来进行绘图。
- 他们无法以方便的格式显示数据。我想在一个或两个窗口中显示数据和绘图,以便它们同时可见。
- 这是一个 win32 控制台应用程序——所有代码都是可移植的。
- 将在调试期间使用这些。
- 免费或付费。
虽然我正在寻找特定的东西,但对于任何使用数组和矩阵进行数值计算的人来说,要求基本上是相同的——同时显示数据和绘图。 我希望这样的工具已经被编写出来并且可用。 我也愿意接受一种解决方案,将数组数据输出到 Excel 工作表(可以保持 Excel 打开),如果它也可以绘图,那就太好了,但我可以不绘图。
PS:我只在调试代码时需要这个。
First post here. Using C in Visual Studio 2008. Can work with VS 2005 if necessary.
- How do I display numerical data in arrays as in a spreadsheet?
- How do I plot numerical data in arrays?
These seem to be simple questions. But I cannot find solutions. So far, I would print the data to a file, import into Excel and view/plot. However, with this code there are too many arrays--so the print/import/plot is tiring.
Some constraints.
- I do not want to write 20+ lines of code to do the above. MATFOR or Array Visualizer let you do the plotting with a one line function call.
- They cannot display the data in a convenient format. I would like to display the data and the plot in one or two windows so that they are visible simultaneously.
- This is a win32 console application---all the code is portable.
- Will be using these during debugging.
- Free or paid.
While I am looking for something specific, the requirements are substantially the same for any one doing numerical work with arrays and matrices--displaying data and plot simultaneously.
I am hoping that a such a tool has been written and is available.
I am also open to a solution that outputs the array data to an Excel sheet (can keep Excel open) and if it can also plot that can be great but I can live without plotting.
PS: I need this only when debugging the code.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
我使用 ArrayDebugView 这是一个安装在 Visual Studio 中的插件,可以在调试时从数组中绘制图形您的申请。它作为调试模式下变量监视的可视化方式工作。您不需要编写一行代码。
I use ArrayDebugView which is a plug-in you install in Visual studio and draws graphs out of arrays while you are debugging your application. It works as a visual way of variable watch in debug mode. You don't need to write a line of code.
我想不出有哪个库可以用不到 20 行代码在控制台应用程序中实现您想要的功能。我的建议是使用 MATLAB 或 GNU Octave 编写绘图步骤脚本来进行实际绘图。
I can't think of any library that would enable what you want in a console app in less than 20 lines of code. My suggestion would be instead to script the plotting-step using MATLAB og GNU Octave to do the actual plotting.
为了显示数组中的数值数据,你应该将指向你想要观察的第一个数据元素的指针添加到手表中——如果你想从头开始观察数组,它只是数组名称,是指向第一个元素的指针。为了查看多个元素,您可以在指针后添加一个“,”,后跟要观察的元素数量。
例如,为了观察
float farray[100];
的元素,您应该添加到手表farray,100
。为了绘图,您可以从手表复制粘贴到绘图软件(即excel)中,但这不是很方便,因为您不能单独复制数据列,但也不能复制左侧和右侧的列,所以它涉及额外的手动编辑。
In order to display numerical data in array, you should add the pointer to the first data element you want to observe, into the watch --- if you want to observe the array from the beginning, it would just be the array name, which is the pointer to the first element. In order to view more then one element, you add a "," after the pointer, followed by the number of element you want to observe.
For example, in order to observe the elements of
float farray[100];
, you should add to the watchfarray,100
.In order to plot, you can copy-paste from the watch to your plotting software (i.e. excel), but it is not very convenient as you cannot copy the data column alone, but the columns to the left and right as well, so it involves extra manual editing.
我使用 GNUPlot (http://www.gnuplot.info/) 来显示我的性能/加速测量。
我将数字打印到标准输出,并编写了一个 bash 脚本,该脚本组合了这些数字并调用 gnuplot 进行渲染。
I use GNUPlot (http://www.gnuplot.info/) to display my performance/speedup measurements.
I print my numbers to stdout and wrote a bash script that combines these numbers and calls gnuplot for rendering.
为此我制作了一个简单的绘图程序。只有一个文本框,我在其中粘贴数据,还有一个图表在其中绘制。
数据需要采用以下任一形式:
大多数我用来绘制跟踪点数据的时间。
我复制/粘贴 VS 的整个输出窗口,绘图程序会忽略任何不遵循这两种形式的内容(因此我不必清理字符串并将其放入 Excel 等)。
它可以绘制线图、点图、柱图、面积图并保存图像、复制到剪贴板。
小情节
I made a simple plotting program for that purpose. There is only a textbox where I paste the data and a chart where it's drawn.
The data needs to be in either form:
Most of the time I used to plot data from tracepoints.
I copy/paste the whole output window of VS, the plotting program ignores anything that doesn't follow these 2 forms (so I don't have to cleanup the string and put it in excel and all).
It does line, point, colum, area charts and save image, copy to clipboard.
MiniPlot
有多种方法可以做到这一点,但这需要编写一些代码。可视化数据通常是简单和直接的,但是完全按照您希望的方式可视化数据将需要一些额外的代码和工作。
有多种选项可用于可视化数据:
BASH 和 GNUPLOT 的组合
使用 MATLAB 或 OCTAVE 进行所有计算和可视化
使用 PYTHON、SciPy 和 matlibplot 库。
Gnuplot 是一个很棒的绘制数据的工具,但使用起来很麻烦。如果你投入时间来获得正确的绘图,并与 LaTeX 完美结合,并且对任意函数都有很好的实现,那么它看起来棒极了。访问 http://gnuplot-tricks.blogspot.ch/ 很棒的网站,了解有关 gnuplot 的所有信息。
MATLAB 等数值程序及其开源等效项 OCTAVE 非常出色,因为它们是数值程序的快速实现语言,并且拥有大量附加库(尤其是 MATLAB)。对于高负载数值计算,它确实很慢,并且绘图库仅适用于基本绘图需求。
使用 PYTHON 及其科学编程库(SciPy 和 matlibplot)是一个很好的组合。这使得出色的绘图不再像 gnuplot 到 plrogram 那样神秘,而且它在绘图方面比 MATLAB 更灵活。此外,它还为您提供了像 MATLAB 一样的数值编程环境。
There are several ways to do this but this will require writing some code. Visualizing data is generally easy and straight forward but visualizing data exactly the way you want them to look will require some additional code and work.
There are several options to visualize data:
A combination of BASH and GNUPLOT
Use MATLAB or OCTAVE for all your calculations and visualization
Use PYTHON and SciPy and matlibplot libraries.
Gnuplot is a great tool to plot data but it is cumbersome to use. It looks fabulous if you invest time to get the plots right and combines excellent with LaTeX and has a good fit implementation for arbitrary functions. Visit http://gnuplot-tricks.blogspot.ch/ great site to learn all about gnuplot.
Numerical programs such as MATLAB and it's open source equivalent OCTAVE are great because they are fast implementation languages for numerical programs and have extensive additional libraries especially MATLAB. For high load numerical computing it is really slow and the plot library is only good for basic plotting needs.
Using PYTHON and its scientific programing libraries (SciPy and matlibplot) are a great combination. This allows excellent plot which are not as cryptic as gnuplot to plrogram and it is more flexible than MATLAB in plotting. Additionally it gives you a environment for numerical programing like MATLAB.