【2023最新】Matlab 保存JSON数据集文件,并用Python读取

1 问题

我想用json格式保存MATLAB生成是数据集,包括数据data,数据Label。然后用python读取JSON文件作为训练集。

2 实现

(1)MATLAB生成json 文件

s.X = data
s.Y = label
s.modulate ='BPSK'
t = jsonencode(s)
file= fopen('test.json', 'w+');
fprintf(file, '%s',t);
fclose(file)

(2)python读取JSON文件

with open('test.json', 'r') as j:
     contents = json.loads(j.read())
contents

猜你喜欢

转载自blog.csdn.net/weixin_43935696/article/details/129072866