How to use RESTful webservices in Matlab

前端 未结 2 2111
傲寒
傲寒 2021-01-03 04:12

I have a data provider that provides a web-based RESTful interface. I\'m trying to get that data into Matlab. The interface is relatively simple, but I\'m still looking for

相关标签:
2条回答
  • 2021-01-03 04:46

    If the RESTful interface returns JSON, it looks like it's as easy as installing a little plugin:

    http://www.mathworks.com/matlabcentral/fileexchange/20565

    and ((almost) direct from the readme of that plugin):

    google_search = 'http://ajax.googleapis.com/....'; 
    matlab_results = parse_json(urlread(google_search));
    

    I guess that's a nice thing about RESTful interfaces over SOAP or whatever is that you don't need excessive machinery to deal with it. I'm sure if the interface isn't returning JSON it will be something similar you can parse.

    0 讨论(0)
  • 2021-01-03 04:47

    MATLAB R2014b can do this natively: http://uk.mathworks.com/help/matlab/ref/webread.html

    For example:

    api = 'http://climatedataapi.worldbank.org/climateweb/rest/v1/';
    url = [api 'country/cru/tas/year/USA'];
    S = webread(url)
    
    0 讨论(0)
提交回复
热议问题