0

How can i access and plot all variables from .mat file, without specifying keys of variables in code?

How can i "parsing" .mat file?

    import scipy.io
    mat = scipy.io.loadmat('D:\\PROJECT\\mat files\\test.mat')
    from pylab import *
    print mat["TEMPERATURE_V1_Max"]
    time = []
    val = []
    for i in range(0,len(mat["TEMPERATURE_V1_Max"])):
        time.append(mat["TEMPERATURE_V1_Max"][i][0])
        val.append(mat["TEMPERATURE_V1_Max"][i][1])
    plot(time, val)
    ##savefig('D:\PROJECT\mat files\test' + '.png')
    show() 

The .mat file can be found here.

4

2 回答 2

1

Thanks!

Now it works:

    import scipy.io
    mat = scipy.io.loadmat('D:\\PROJECT\\mat files\\test.mat')
    from pylab import *

    dictMain = []
    dict_var = {"Time": [], "Value" : []}


    for key in mat.keys():
        for temp in mat[key]:
            dict_var["Time"].append(temp[0])
            dict_var["Value"].append(temp[1])
           ## plot(dict_var["Time"], dict_var["Value"])
           ## show()
        dictMain.append(dict_var)
于 2013-06-12T15:23:04.980 回答
0

所有映射都应遵循映射协议。假设通过加载 .mat 文件创建的对象是正确的映射,您可以对其使用任何这些操作,包括返回键、值和项的方法。

于 2013-06-12T04:12:50.997 回答