Function output 'data' cannot be of MATLAB type
Show older comments
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()"
"
Answers (1)
Walter Roberson
on 4 May 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
Categories
Find more on MATLAB Coder in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!