MATLAB连接API接口

本文介绍了MATLAB中用于连接API接口的三个关键函数:weboptions、webread和webwrite。通过设置weboptions,你可以定制HTTP请求的参数,然后使用webread获取API的数据,或者使用webwrite向API发送数据。示例中展示了如何构造查询结构体并使用webwrite进行登录操作。
摘要由CSDN通过智能技术生成

matlab连接API接口常用的几个函数分别为:weboptions、webread、webwrite;不同函数对应的解释分别可以查官网即可;
weboptions:https://ww2.mathworks.cn/help/matlab/ref/weboptions.html
webread:https://ww2.mathworks.cn/help/matlab/ref/webread.html
webwrite:https://ww2.mathworks.cn/help/matlab/ref/webwrite.html
这里就不做过多介绍了。

matlab连接起来也是比较方便的,

clc
clear
%登录
URL = '你自己的URL';
%对应的API查询结构体,不同接口不一样,根据实际情况来即可
body = struct(...
    'op', 'all',...
    'options', struct(...
        'select', struct(...
            'ObjectCode', 0,...
            'CollectTime', 1,...
            'InsertTime', 2,...
            'PointValue1', 3,...
            'PointValue2', 4,...
            'PointValue3', 5,...
            'PointValue4', 6,...
            'PointValue5', 7,...
            'PointValue6', 8,...
            'PointValue7', 9,...
            'PointValue8', 10,...
            'PointValue9', 11,...
            'PointValue10', 12 ...
        ), ...
        'sort', {{
            'CollectTime'
        }},...
        'limit', 10000 ...
    )...
);
response = webwrite(URL,jsonData)
  • 2
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值