有没有办法在 Perl 中读取 MATLAB 的 .mat 文件?

发布于 2024-08-27 20:21:08 字数 162 浏览 7 评论 0 原文

我在 MATLAB 中生成了一些数据,我想使用 Perl 对其进行处理。我将 MATLAB 中的数据保存在 .mat 文件中。有没有办法用 Perl 阅读它?

I have some data generated in MATLAB that I want to process using Perl. I saved the data from MATLAB in a .mat file. Is there any way to read it in Perl?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

白日梦 2024-09-03 20:21:08

一种选择是使用以下内容从 MATLAB 内部将二进制 MAT 文件另存为 ASCII:

load('test_data.mat');
save('test_data.asc', 'var1', 'var2', '-ascii');

然后您将在 Perl 中处理 ASCII 数据。

如果您需要完全用 Perl 编写的解决方案,那么您应该能够使用 自动化该过程CPAN 上的 Math::MATLAB 包。

注意:如果可以选择 Python,则可以使用 SciPy Python 库 中的 >loadmat 函数。

One option would be to save the binary MAT file as ASCII from inside MATLAB using something like:

load('test_data.mat');
save('test_data.asc', 'var1', 'var2', '-ascii');

Then you would have ASCII data to process in Perl.

If you need a solution completely written in Perl, then you should be able to automate the process using the Math::MATLAB package on CPAN.

NOTE: If Python is an option, you could use the loadmat function in the SciPy Python library.

九公里浅绿 2024-09-03 20:21:08

Java 库 JMatIO 对我来说效果很好。也许你可以尝试使用内联Java

The Java library JMatIO has worked well for me. Maybe you can try using inline Java.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文