Function output 'data' cannot be of MATLAB type

function data = readtxt()
fid = fopen('data_out.txt');
data=fscanf(fid,'%5d',inf);
fclose(fid);
end
This Function can run in matlab without any error.But in "Embedded MATLAB Function" of simulink result in some error.
"Function output 'data' cannot be of MATLAB type.
Function 'Embedded MATLAB Function' (#56.0.108), line 1, column 1:
"function data = readtxt()"
"

Respuestas (1)

Walter Roberson
Walter Roberson el 4 de Mayo de 2013
Initialize data before assigning to it.
Michael Hosea wrote,
Your return values are mxArrays and can't mix
with your Embedded MATLAB data. If you know the size and type, you can
pre-declare it, and the compiler will generate the necessary code to convert
an mxArray to a native C data type

Categorías

Más información sobre MATLAB Coder en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

ka
el 4 de Mayo de 2013

Community Treasure Hunt

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

Start Hunting!

Translated by