How to get xml-Data in Simulink
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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
0 comentarios
Respuestas (1)
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.
Ver también
Categorías
Más información sobre Simulink Functions en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!