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