圖片名稱
全部
  • 全部
  • 產(chǎn)品管理
  • 新聞資訊
  • 介紹內(nèi)容
  • 企業(yè)網(wǎng)點(diǎn)
  • 常見(jiàn)問(wèn)題
  • 企業(yè)視頻
  • 企業(yè)圖冊(cè)

公告:

安諾尼實(shí)時(shí)頻譜儀如何使用MATLAB進(jìn)行二次研發(fā)(1)

作者: 安諾尼AARONIA

來(lái)源: 安諾尼AARONIA

發(fā)布時(shí)間:2022-07-04 07:26

1、如何建立與Matlab的實(shí)時(shí)HTTP連接

安諾尼RTSA-Suite PRO實(shí)時(shí)頻譜儀軟件提供了一個(gè)支持JSON數(shù)據(jù)格式,強(qiáng)大的HTTP服務(wù)器模塊,使用它的RESTful web service建立一個(gè)與Matlab的實(shí)時(shí)HTTP連接是非常簡(jiǎn)單的。

示例請(qǐng)參考:https://de.mathworks.com/help/matlab/ref/webread.html

2、如何從服務(wù)器轉(zhuǎn)換JSON文本的其他信息

參考示例:

https://de.mathworks.com/help/compiler_sdk/mps_dev_test/mps.json.decoderesponse.html?searchHighlight=json&s_tid=srchtitle#d123e13998

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

3、如何發(fā)送和接收HTTP信息

參考示例:

https://de.mathworks.com/help/matlab/ref/matlab.net.http.requestmessage.send.html

 

《安諾尼實(shí)時(shí)頻譜儀如何使用MATLAB進(jìn)行二次研發(fā)》的相關(guān)內(nèi)容將以連載的方式進(jìn)行更新,這是連載的第1期,感謝您的閱讀。

關(guān)鍵詞:

相關(guān)企業(yè)下載

暫時(shí)沒(méi)有內(nèi)容信息顯示