How to get xml-Data in Simulink

조회 수: 6 (최근 30일)
Andreas
Andreas 2013년 7월 15일
Hello, i want to make a simulink model, where a xml-file can be read every single time step. Therefore I used the xmlread-function in a Matlabfunction-block as u can see below.
coder.extrinsic('xmlread')
xDoc=[];
xDoc=xmlread('OUTPUT_PIN_DATA_Matlab.xml');
a=str2double(xDoc.getElementsByTagName('o').item(0).getAttribute('p0'));
The used xml-file looks like this:
<?xml version="1.0"?>
<e id="9">
<i p0="4.332"/>
<o p0="21.66"/>
</e><e id="32">
<i p0="85.0"/>
<o p0="94.53"/>
</e>
I get an error message: Referencing a component from array of non-scalar values is not supported for code generation. Is it even possible to get the data of a xml-file in Simulink? Or is the Matlabfunction the problem? In Matlab I don't have that problem. I can read the data with the same code in the workspace... Thank you very much

답변 (1개)

Kaustubha Govind
Kaustubha Govind 2013년 7월 15일
I'd recommend that you use an Interpreted MATLAB Function block or a MATLAB S-function block to implement this. The MATLAB Function block that you are currently using needs to generate C code from the MATLAB code for execution. However, XMLREAD is not compatible with code generation. Instead, you should use blocks that don't attempt to generate code from the MATLAB code.
  댓글 수: 1
Andreas
Andreas 2013년 7월 15일
So it is possible to convert this Code into C-Code or a S-Function? What is faster in Simulink? I have to say, I dont really get the problem. Everything works just fine in Matlab. I Run the m-File and get the data in my workspace. Why doesnt that work in Simulink? Or is there an easier way to get data from a xml-file into Simulink?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Simulink Functions에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by