how do i give xxx.txt file as input to Embedded Matlab Function in simulink model
3 views (last 30 days)
Show older comments
Hi,
I am new to Simulink. I have written a function in matlab, which converts text to binary. Now i want to include this function in my simulink model. I can use Embedded Matlab Function block to do this. Since the input to this block is a txt file, i do not know how to feed it.
Please help me.
Thanks Parvathi.
0 Comments
Answers (2)
TAB
on 13 Aug 2012
Edited: TAB
on 13 Aug 2012
Simulink can not use text file as input.
You can use matlab functions like fopen, fread, fclose in simulink inside Matlab function block declaring them as extrinsic to read/write text file.
But it is inefficient and not a good idea to read or write text or binary files from simulink. Instead you can use matlab script for this purpose. If some data is needed from simulink, save/log the data in the base workspace and use it in the m-script.
0 Comments
Konark Kelaiya
on 13 Aug 2012
Yes..
Make MATLAB function script file to read the data from xxx.txt file , wherein there are lots of handy function which can read the data from text.
Later on save those data to workspace or file as mat and add simulink block either i/p from workspace / i/p from file to get those data into simulink.
more, using extrinsic in MATLAB simulink function doesn't work for all the function available within MATLAB toolbox
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!