Coder Error with Simulink Embedded function using "fopen": Expected either a logical, char... Found an mxArray )
Mostrar comentarios más antiguos
Embedded function: should check if the file is available to be written. If yes, file is written fid is a parameter u is an input
function Matlab_to_WM(u, fid)
coder.extrinsic('dlmwrite');
coder.extrinsic('fopen');
coder.extrinsic('fclose');
fid=fopen('D:\damien\Echange_donnees_System\Consigne_Retour_94A.txt', 'w');
if fid ~= -1 && fid ~= 2
dlmwrite('D:\damien\Echange_donnees_System\Consigne_Retour_94A.txt' , u , 'newline', 'pc');
end
fclose('all');
end
The result of "fopen" gives a mxArray (1 x 1) Then the test on fid value generate an error: "Expected either a logical, char, int, fi, single, or double. Found an mxArray. MxArrays are returned from calls to the MATLAB interpreter and are not supported inside expressions. They may only be used on the right-hand side of assignments and as arguments to extrinsic functions."
This function, was working with the 2007b version and don't work anymore with 2012a version. Then, how to test a mxArray or to extract the value(1 x 1) as a double?
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre MATLAB Coder en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!