欢迎光临深圳市拓力智慧科技有限公司!!
手机网站 | 联系我们:0755-88858086-613 | 加入收藏
  • 技术文章

    AARONIA实时频谱分析仪使用MATLAB进行二次研发(1)

    2022-07-11 16:33:28  来源:安诺尼AARONIA
    MATLAB是美国MathWorks公司出品的商业数学软件,用于数据分析、无线通信、深度学习、图像处理与计算机视觉、信号处理、量化金融与风险管理、机器人,控制系统等领域。它将数值分析、矩阵计算、科学数据可视化以及非线性动态系统的建模和仿真等诸多强大功能集成在一个易于使用的视窗环境中,为科学研究、工程设计以及必须进行有效数值计算的众多科学领域提供了一种全面的解决方案,并在很大程度上摆脱了传统非交互式程序设计语言(如C、Fortran)的编辑模式。

    1、AARONIA实时频谱分析仪如何建立与Matlab的实时HTTP连接?
    AARONIA实时频谱分析仪软件RTSA-Suite PRO提供了一个支持JSON数据格式,强大的HTTP服务器模块,使用它的RESTful web service建立一个与Matlab的实时HTTP连接是非常简单的。

    2、如何从服务器转换JSON文本的其他信息?
    参考示例:
    mps.json.decoderesponse

    Convert JSON text from a server response to MATLAB data

    Syntax

    lhs = mps.json.decoderesponse(response)

    error = mps.json.decoderesponse(response)

    Description

    example

    lhs = mps.json.decoderesponse(response) reads the JSON payload of the output arguments returned from a successful MATLAB function call.

    error = mps.json.decoderesponse(response) reads the JSON payload of the MATLAB error thrown from a failed MATLAB function call.

    Examples

    collapse all

    >Read from MATLAB Production Server Payload

    mps.json.decoderesponse('{"lhs":[[[1, 2, 3, 4]]]}')

    ans =

      1x1 cell array

        {1x4 double}

    Read response from a sortstudent function deployed on MATLAB Production Server

    Execute mps.json.encoderequest and mps.json.decoderesponse to call a function deployed on MATLAB Production Server using webwrite. In this case, student names and their corresponding scores are deployed to MATLAB Production Server to the sortstudents function that sorts students based on their scores. The result returned is the equivalent to calling the function sortstudents(struct('name', 'Ed', 'score', 83), struct('name', 'Toni', 'score', 91)) from MATLAB.

    Assume that there is a deployable archive studentapp that contains a MATLAB function sortstudents deployed to the server.

    data = {struct('name', 'Ed', 'score', 83), struct('name', 'Toni', 'score', 91)};

    body = mps.json.encoderequest(data);

     
    options = weboptions;

    % Create a weboptions object that instructs webread to return JSON text

    options.ContentType = 'text';

    % Create a weboptions object that instructs webwrite to encode character vector data as JSON to post it to a web service

    options.MediaType = 'application/json';    

     
    response = webwrite('http://localhost:9910/studentapp/sortstudents', body, options);

    result = mps.json.decoderesponse(response);

    Input Arguments

    collapse all

    response — JSON result from a MATLAB function call
    char (default)

    JSON result from a MATLAB function call specified as JSON text.

    Output Arguments

    collapse all

    lhs — Cell vector of output arguments
    Cell vector

    Cell vector of output arguments that are from a MATLAB function called from MATLAB Production Server.

    error — Generated output when request results in a MATLAB error
    struct array

    Generated output when request to MATLAB function called from MATLAB Production Server results in a MATLAB error returned as a struct array.

    Version History

    Introduced in R2018a

    See Also

    mps.json.encode | mps.json.decode | mps.json.encoderequest

    Topics

    JSONRepresentation of MATLAB Data Types (MATLAB Production Server)

    Create Deployable Archive for MATLAB Production Server (MATLAB Production Server)

    3、如何发送和接收HTTP信息
    参考示例:
    send
    类: matlab.net.http.RequestMessage
    包: matlab.net.http

    语法
    [response,completedrequest,history] = send(request,uri)
    [response,completedrequest,history] = send(request,uri,options,consumer)

版权所有 © 深圳市拓力智慧科技有限公司
联系人:李明辉  联系电话:0755-88858086-613  传真:
联系地址:广东省深圳市龙岗区联李东路10号海大科技园2栋8806

技术支持:谷瀑     免责申明     粤ICP备11062183号