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

Risposte (1)

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

Categorie

Scopri di più su MATLAB Coder in Centro assistenza e File Exchange

Tag

Richiesto:

ka
il 4 Mag 2013

Community Treasure Hunt

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

Start Hunting!

Translated by