如何在 google colab 中运行 matlab .m 文件
Posted
技术标签:
【中文标题】如何在 google colab 中运行 matlab .m 文件【英文标题】:How to run matlab .m files in google colab 【发布时间】:2019-10-18 09:02:39 【问题描述】:我目前正在尝试运行这个 repo https://github.com/Fanziapril/mvfnet 这需要一个步骤:
"Run the Matlab/ModelGeneration/ModelGenerate.m to generate the shape
model "Model_Shape.mat" and copy it to the Matlab/"
是否可以在 colab 中运行 .m
文件来执行此操作?
另外,我研究了 oct2py 库 https://blink1073.github.io/oct2py/, 但无法成功运行该文件。 我关注了这个How to run a MATLAB code on Python
【问题讨论】:
我认为 Google Colab 只能通过 iPython notebook 运行 iPython notebook 和一些 bash 命令,所以你可以尝试通过将 .m 文件上传到 Colab 并使用!matlab file.m
来运行它(基本上替换 matlab可能使用 octave 或其他可以安装在 Colab 中的 MATLAB 编译器,并且您在命令前使用感叹号表示它要像 bash 命令一样运行)。
【参考方案1】:
你需要先安装octave
!apt install octave
然后你可以运行你的 m 文件
!octave -W file.m
这是minimal example。
【讨论】:
生成 mat 文件后,我得到 raise ValueError('Unknown mat file type, version %s, %s' % ret) ValueError: Unknown mat file type, version 57, 54以上是关于如何在 google colab 中运行 matlab .m 文件的主要内容,如果未能解决你的问题,请参考以下文章