How to save max data of a time series data from simulink

2 ビュー (過去 30 日間)
joms
joms 2019 年 9 月 6 日
回答済み: RSaha 2019 年 9 月 9 日
I have an output from simulink of the following array. It calculates Kw value per 0.1 seconds i want to get total kw when "valid "array is 1 either in simulink or in matlab
valid=[0 0 0 0 0 0 1 1 1 1 1 1 0 0 0 0 0 1 1 1 0 0 0 ]
kwdata=[0 0 0 0 0 0 2 3 4 5 5 2 0 0 0 0 0 1 2 3 0 0 0]
Desired output
Desired output=[sum[2 3 4 5 5 2] sum[1 2 3]]
Desiredout=[21 6]/0.1

回答 (1 件)

RSaha
RSaha 2019 年 9 月 9 日
s=find(diff(valid)==1);
e=find(diff(valid)==-1);
Desiredout=[sum(kwdata(s(1):e(1))) sum(kwdata(s(2):e(2)))]/0.1;

カテゴリ

Help Center および File ExchangeSimulink についてさらに検索

製品


リリース

R2013b

Community Treasure Hunt

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

Start Hunting!

Translated by