how do i give xxx.txt file as input to Embedded Matlab Function in simulink model

6 vues (au cours des 30 derniers jours)
Parvathi
Parvathi le 11 Août 2012
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.

Réponses (2)

TAB
TAB le 13 Août 2012
Modifié(e) : TAB le 13 Août 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.

Konark Kelaiya
Konark Kelaiya le 13 Août 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

Catégories

En savoir plus sur Prepare Model Inputs and Outputs dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by