How to get xml-Data in Simulink

6 visualizaciones (últimos 30 días)
Andreas
Andreas el 15 de Jul. de 2013
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

Respuestas (1)

Kaustubha Govind
Kaustubha Govind el 15 de Jul. de 2013
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 comentario
Andreas
Andreas el 15 de Jul. de 2013
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?

Iniciar sesión para comentar.

Categorías

Más información sobre Simulink Functions en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by