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

12 次查看(过去 30 天)
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

采纳的回答

Sulaymon Eshkabilov
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

更多回答(1 个)

Sulaymon Eshkabilov
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 个评论
Morteza Ghafoori
Morteza Ghafoori 2019-5-4
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?

请先登录,再进行评论。

类别

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

产品


版本

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by