I have a Constant block with the following value: uint8('120percent.txt'). I pass this value as an input to my Level2 MS Function. I've set the associated Inputport.Dimensions to be dynamic i.e. adapting to the size of the string.
At the Outputs method, I made a local variable that reverses the InputPort.Data back to its string value using the following command: FileName = char(block.InputPort(1).Data);
When I run my file, I receive an error saying: "the file cannot be found or permission denid," and it points out at the line code which says: text_lines = length(dataread('file', FileName, '%s', 'delimiter', '\n'));
Although I have, in this Level2 Function, used FileName before declaring text_lines when I declared the 'fid' variable as the following: fid = fopen(FileName); and it didn't complain at that line, but it went further down my code and the error message pointed out at the 'text_lines' code line.
Any reasons why the 'length' and/or 'dataread' functions aren't wlecoming the char() function inside it, or why am I having that error in the first place.
Here's my code for your observations: __________________________________________________ function Level2_WF_iv(block) setup(block);
function setup(block) % Register number of ports. block.NumInputPorts = 2; % d from the Entity Gen. block. block.NumOutputPorts = 10;
% Setup port properties to be dynamically inherited. block.SetPreCompInpPortInfoToDynamic; block.SetPreCompOutPortInfoToDynamic;