matlab 如何在VS Code中查看.mat文件?

mjqavswn  于 8个月前  发布在  Matlab
关注(0)|答案(1)|浏览(552)

我想在我的VS代码中打开一个Matlab的.mat文件,而无需在我的机器中安装Matlab环境。但是,我找不到任何扩展来这样做。我的系统是macOS。谢谢你的任何想法!

piv4azn7

piv4azn71#

您可以使用scipy加载.mat文件,然后使用Data Viewer对其进行可视化。首先需要安装VSCode的Python和Python扩展。
下面是一个非常基本的示例:

from   scipy.io   import  loadmat
import numpy      as      np
matrixVar = loadmat( "someMatrix.mat" )

# Do whatever data manipulation you need here
# Let's do a simple transpose for the sake of the example.
mainpulatedData = np.transpose(matrixVar)

# Do more stuff here if needed
# ...
print( 'Done processing' )

要打开Data Viewer,请在加载和处理数据的行后放置一个断点,然后以Python模式运行Python。在右侧,右键单击感兴趣的变量(本例中为mainpulatedData)并选择View Value in Data Viewer
This is how you access the Data Viewer
Here is an example of what it should look like
我不知道为什么社区中的一些成员早些时候与你就语义和定义争论一个没有意义的问题,但我猜他们每个人都有自己的观点。
祝你好运!

相关问题