Transferring Simulink scope data into Matlab as arrays

I'm trying to import data from Simulink into Matlab. I want to create an array of time values and an array of data values (corresponding to the particular time).
Right now I'm using an output block in Simulink and saving the data as a timeseries. I know that the timeseries is being correctly created because I can open up the timeseries and view the data (which consists of time and a corresponding data value). I am also able to open the timeseries within a Matlab "M" file.
I need to decompose the data into an array of time values and an array of data values. Thus far I have an array of data using the following code (OPD is the timeseries):
i = 1:1:(size(OPD));
position = getdatasamples(OPD, i);
Now I need an array of the time corresponding to each of the data points.
Thank you for any help you can provide! Perhaps there's an easier way I'm not seeing

답변 (1개)

Thor
Thor 2012년 2월 25일
Figured it out!
By changing the 'Save format' to 'Array' instead of 'Timeseries' in the 'To File' Simulink output block, I was able to make separate arrays of time and data using the following code (OPD is the variable name within the 'To File' block):
time = OPD(1,:);
position = OPD(2,:);
I hope this will help someone else!

댓글 수: 2

Thanks for following up with a fix!! 6 years later- your update has been useful! I was looking exactly for this!
Many thanks from the future.
And from the even more distant future!

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Simulink에 대해 자세히 알아보기

질문:

2012년 2월 25일

댓글:

2022년 7월 23일

Community Treasure Hunt

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

Start Hunting!

Translated by