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
0 个评论
采纳的回答
Sulaymon Eshkabilov
2019-5-5
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
2019-5-4
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, :)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!