|
Hi,
Here is a test text file content I'm dealing with:
1 2 3 4 5 6 7
2 4 6 3 6 7 4
6 3 5 3 6 7 4
5 6 7 3 6 3 4
...
How can I read one particular line at a time inside Embedded Matlab function. I've developed the following code inside an Embedded Matlab function in SimEvents:
function Task = fcn(Count) % Count is the number of the specific line I want to extarct/read
Task = zeros(1, 1);
C = zeros(1, 1);
eml.extrinsic('fopen', 'textread', 'fclose')
fid = fopen('file.txt');
C = textread('file.txt', '%s', 'delimiter', '\n');
Task = C(Count);
fclose(fid)
I get the following errors:
1. Embedded MATLAB Interface Error: MATLAB expression 'textread' is not numeric. This error highlights the whole Embedded Matlab function block.
2. I used get the following error: Subscripting into an mxArray is not supported. I think I solved it by setting the size of Task and C in the beginning. However, I'm not sure whether I need to declare both or only Task in the beginning.
I've tried 'textscan' also, and it has the same errors above.
looking forward your comments, cheers.
____________
Tiger
|