how to get the last row of data of a time series when I dont know how many rows that time series has

12 views (last 30 days)
Hello, so I have a simulink model that gives me various variables and one of them is a time series. Let's suppose that the variable name is R and I want to get the last row of its data, I know that the data has 9 columns but the number of rows is unkown, any idea how to get that last row of data?
I've tried getdatasamples(R,end) but it doesn't work. Thanks for the help

Accepted Answer

Sulaymon Eshkabilov
Sulaymon Eshkabilov on 5 May 2019
Hi,
Of course it is possible. Here are the answers step - by - step.
1) if you have an array saved under variable name R, then: >> R(end, :)
2) if you have one time series (signal) variable and your output variable in the workspace (e.g. it is called: Sout), then:
>> Sout.Data(end,:) % ==> would give you the last value of the collected signal from your simulink model.
3) If you have two time series signals saved under one variable name (e.g. Sout), then:
>> Sout.signal1.Data(end,:) %==> would give you the last value of the collected signal 1
>> Sout.signal2.Data(end,:) % ==> would give the last value from the signal 2
4) if you have saved your signals (e.g. one, two, three, four .... signals) as a structure variable with time series called STout, then:
>> STout.signals.values(end,:)
5) if you have saved your signals (e.g. one, tow, three, four, ... signals) as a structure variable called SSout, then
>> SSout.signals.values(end,:)
Good luck

More Answers (1)

Sulaymon Eshkabilov
Sulaymon Eshkabilov on 4 May 2019
Let's say you have saved your variable R data into MATLAB workspace, then to get the last row of R, this is the command:
R(end, :)
  1 Comment
Morteza Ghafoori
Morteza Ghafoori on 4 May 2019
That would work if the variable R was saved as an array in the workspace. But what if it was a time series? Is it even possible to get the last row of its data?

Sign in to comment.

Categories

Find more on Simulink in Help Center and File Exchange

Products


Release

R2018a

Community Treasure Hunt

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

Start Hunting!