matlab load pkl

function [a] = loadpickle(filename)
  if ~exist(filename,'file')
    error('%s is not a file',filename);
  end
  outname = [tempname() '.mat'];
  pyscript = ['import pickle;import sys;import scipy.io;file=open("' filename '", "rb");dat=pickle.load(file);file.close();scipy.io.savemat("' outname '.dat")'];
system(['python -c "' pyscript '"']);
a = load(outname);
end
 

 

特别不鲁棒的解决方案,不建议使用

posted @ 2020-07-26 17:13  bH1pJ  阅读(81)  评论(0编辑  收藏  举报