How to: Make a simulink block to read in a data file?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
I posted this to the general newsgroup, but no replies.
I have several situations where we have data in a column separated fields in a file.
I want to start using simulink because it provides an automatic visual understanding of the processing steps.
There are methods for creating a simulink block to read in a *.mat file, but I cannot figure out how to make a simulink block that reads in an ASCII file, and provides the data as column vectors: one column per entry.
Can someone please provide an example of how this would be done?
0 Kommentare
Antworten (1)
Nirmal Gunaseelan
am 11 Aug. 2011
I am not aware of a block in Simulink that can read from a normal ASCII file (you could potentially write your own Level-2 MATLAB file S-function). There might be an easier way to do this by using MATLAB scripts (that could use TEXTREAD or related functions).
This MATLAB script can then be called in the model initialization section so that the data is available in the workspace before simulation starts.
Alternatively this script could write to a MAT-file (and not have any variables in the workspace) and you could use Simulink's From-file block to read in the data during simulation.
2 Kommentare
Nirmal Gunaseelan
am 12 Aug. 2011
There is also something called a MATLAB-function block (http://www.mathworks.com/help/toolbox/simulink/ug/f6-106261.html) that you can mask and read in a file name. A script can then be called from this block and the outputs could be the data from the file read in through the script. Would that work in your case?
I was considering code-generation options in my previous answer and code-generation would not be supported using MATLAB-function block at all times (many functions are supported though).
Siehe auch
Kategorien
Mehr zu Interactive Model Editing finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!