Read variable values from m-file
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I work on a simulation project containing a large simulink model. Before I could load the input variables to the model directly to the base workspace from a large mat-file. For several reasons we had to change the input file format from .mat to .m. The input variables are each stored in one separate m-file. To read the variables to the base workspace I just run the m-files. Each m-file contains one signal name together with the corresponding simulation values in matrix form. Ex: signalA.m; signal_A = [1 3;2 5;....]; The first column is the time stamp values.
My problem is not to read the variables to the workspace but to obtain the stop time value in the signal matrix. I need the last time value in order to activate the simulink model with the correct simulation time from a main function. Before I could just read the last time stamp value from one signal from the mat-file. Does anyone have any idea how to read the signal values from the m-file in order to obtain the last time stamp value?
4 Kommentare
Image Analyst
am 26 Sep. 2011
I don't understand. Don't you have a line in your m-file that says something like
lastStopTime = signal_A(42);
???
Or do you have a scope problem where you need to call assignin(), evalin(), or something like that?
Antworten (1)
Daniel Shub
am 26 Sep. 2011
The problem seems to be that the simulation wants its inputs in terms of many separate m-files, but that it is easier to work with a single data saved in a single mat-file. What about using a mat-file for everything you have control of and writing a wrapper to create the m-files the simulation wants. Just because one stage wants data in an efficient manner, doesn't mean your entire workflow needs to suffer.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Simulink Functions finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!