Read variable values from m-file

5 次查看(过去 30 天)
Erik
Erik 2011-9-26
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 个评论
Image Analyst
Image Analyst 2011-9-26
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?
Erik
Erik 2011-9-26
I'm sorry if I'm confusing. I just realized that I don’t need a simulation time for the simulink model if you have a time vector. :)
Thank you anyway!

请先登录,再进行评论。

回答(1 个)

Daniel Shub
Daniel Shub 2011-9-26
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.

类别

Help CenterFile Exchange 中查找有关 Simulink Functions 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by