Reputation: 69675
I would like to run a simulation using Simulink, and I would like to use data from a txt file. I have try using
x_ref_n0 = importdata('x_n_ref0.txt');
However, I am getting an error message:
The function 'importdata' is not supported for standalone code generation.
What can I do to solved this issue?
Upvotes: 1
Views: 1757
Reputation: 4477
Are you trying to use importdata inside a MATLAB Function block? You should import the data in the MATLAB workspace and then use "From Workspace" or "Signal From Workspace" blocks to bring the data into simulink. If the data is too large to bring it into workspace, you should read the file a few lines at a time using fopen and then use textscan to parse the data. You can call these functions in many different ways. The stackoverflow question How can I call an m file in Simulink and put it to a block in my model? has many answers to call MATLAB code from Simulink.
If you are instead reading all the data from one file used in one time step from MATLAB Function block then you should declare importdata as extrinsic which will allow you to call a MATLAB function which does not support code generation. Using extrinsic will not support code generation using real time workshop. Simulation should work fine. See documentation for extrinsic at http://www.mathworks.com/help/fixedpoint/ref/coder.extrinsic.html
Upvotes: 1