how to solve error saying 'File "<stdio.h>" does not exist' while generating C++ code from simulink having function block that usages abs or real functions?

5 views (last 30 days)
I have a Simulink model that contains a matlab function block. This function block usage functions such abs() and real(). While generating code from this simulink model I getting an error:
File "<stdio.h>" does not exist.
When I comment the line that usage real() and abs(), code is generated successfully. Why is that? How to solve this problem?
I am using Ubuntu 14.04 with Matlab Version 9.0 (R2016a) and Simulink Code Version 8.10 (R2016a).
Ujjwal Gupta
Ujjwal Gupta on 31 Oct 2022
Edited: Ujjwal Gupta on 31 Oct 2022
Workaround is to use combination of 'fread', 'extractAfter', 'extractBefore', 'str2double', and 'real' instead of 'fscanf' for reading the data, something similar to the follwoing code -
maxBufferSize = 500;
coefdata = zeros(maxBufferSize, 2);
coder.varsize('before', [1,1000])
coder.varsize('after', [1,1000])
text = fread(fileID, [1,1000000], '*char');
i = 1;
text_line = extractBefore(text, newline);
before = extractBefore(text_line, " ");
after = extractAfter(text_line, " ");
coefdata(i,1) = real(str2double(before));
coefdata(i,2) = real(str2double(after));
text = extractAfter(text,newline);
if size(text,1)==0
i = i+1;

Sign in to comment.

Answers (0)


Find more on Simulink Coder in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!