码迷,mamicode.com
首页 > Web开发 > 详细

matlab 读取文件(mat)存储为json文件

时间:2015-03-05 18:59:39      阅读:230      评论:0      收藏:0      [点我收藏+]

标签:

 

fid= fopen(reqJosn.json, w+);
load(request-set-10.mat);
requests = requests.request;
requestNum = length(requests);
for i = 1:1
    request.name = sprintf(%s%d, vn_test_,i);
    request.type = 0;
    request.description = sprintf(%s%d%s, virtual network ,i,  for test use);
    controller.id = i;
    controller.name = defaultController;
    controller.host = localhost;
    controller.port = 6633;
    controller.type = POX;
    request.controller = controller;
    nodeNum = requests(1,i).node_num;
    linkNum = requests(1,i).link_num;
    request.sw_number = nodeNum;
    switches = {};//注意此处如需在结构里嵌套结构,必须这样子
    for j = 1:nodeNum
       swTemp.id = j;
       swTemp.name = sprintf(%s%d, sw, j);
       swTemp.resource = requests(1,i).cpu(j);
       swTemp.port_num = 8;
       swTemp.host_num = 1;
       switches = [switches,swTemp];
    end
    request.switches = switches;
    subJson = savejson(‘‘,request);//幻化为json字符串,具体help一下
    fprintf(fid, %s,subJson);
end
fclose(fid);

 

matlab 读取文件(mat)存储为json文件

标签:

原文地址:http://www.cnblogs.com/hhjiang14/p/4316144.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!