Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: Question about large input data to Simulink
Replies: 0  

Advanced Search

Back to Topic List Back to Topic List  
fl

Posts: 82
Registered: 10/8/05
Question about large input data to Simulink
Posted: Mar 21, 2013 3:07 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Hi,

I have searched on the web on large input data to Simulink. The following link seems like relevant to my question:

http://www.mathworks.com/matlabcentral/newsreader/view_thread/260837

I have tried the method:

b) Using an S-function (either m-code or c-code).
This has the advantage of having clearly defined bits of the code for initialization and termination.
The termination part inparticular overcomes the above problem in using the EML block.

It does not behave like I expect. With other relevant posts, I want to define file handle 'fid' as persistent in Callbacks InitFcn to make file open only once at the beginning. But the error message shows that:

Error evaluating 'InitFcn' callback of block_diagram 'resp1'.

Caused by:
A PERSISTENT declaration is only allowed in a M-file function.

When I remove the persistent fid definition to custom Matlab function, as:

function y = f_data_in()
%#codegen
% persistent fid;
coder.extrinsic('fopen');
coder.extrinsic('fgetl');
coder.extrinsic('str2num');
% fid=fopen('x21A0.txt');
y = 0;
y0 = zeros(1,3, 'double');
tline = fgetl(fid);

y0 = str2num(tline)
y = y0(1,3);
end

The tline will always be the first row data. It is not read each line by Simulink in every step as I wish.

I hope that each Simulink step reads one row data from the large file. In this way, no big computer memory requirement needs at all. Any one can help me on my question?

Thanks in advance.



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.