Read variable values from m-file
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Image Analyst
le 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?
Réponses (1)
Daniel Shub
le 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 commentaires
Voir également
Catégories
En savoir plus sur Simulink Functions 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!