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()"
"

Antworten (1)

Walter Roberson
Walter Roberson am 4 Mai 2013

1 Stimme

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

Kategorien

Mehr zu MATLAB Coder finden Sie in Hilfe-Center und File Exchange

Tags

Gefragt:

ka
am 4 Mai 2013

Community Treasure Hunt

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

Start Hunting!

Translated by