detect smallest or bigest value of signal in stateflow and simulink
古いコメントを表示
hi all..
let say i have 2 signal, first signal is the value (let say S) and second signal is the number of value (let say N), both are vector signal with 10 element(vector(1x10))
S=[3 4 5 7 8 9 11 12 13 14]
N=[1 2 3 4 5 6 7 8 9 10]
and then, i have signal C,
C=20
how if i want to detect the smallest and the biggest gap between element C and S,
for example: let say H was the value off gap between S and C: H= C-S then result H
H= [ 17 16 15 13 12 11 9 8 7 6 ]
how we detect the smallest and the bigest value H, then show the number signal it was from.
example in this case,according H value: the smallest= 6, number of signal= 10 the biggest= 17, number of signal= 1
how we do it in STATEFLOW, SIMULINK OR EMBEDDED MATLAB FUNCTION ??
THANKS,
採用された回答
その他の回答 (2 件)
Fangjun Jiang
2011 年 7 月 13 日
S=[3 4 5 7 8 9 11 12 13 14];
C=20;
H=C-S;
[MinVal,MinInd]=min(H)
MinSignal=S(MinInd)
[MaxVal,MaxInd]=max(H)
MaxSignal=S(MaxInd)
4 件のコメント
Luhur
2011 年 7 月 13 日
Fangjun Jiang
2011 年 7 月 13 日
See updated code.
Luhur
2011 年 7 月 13 日
Fangjun Jiang
2011 年 7 月 13 日
The MinMax block is the right one to use. I have to ask you to clarify what do you mean signal here. When you say S=[3 4 5 7 8 9 11 12 13 14], do you mean the value of the signal S is 3 at time=0, 4 at time=t, 5 at time=2*t, etc? t could be any time step like 0.1 sec or 0.001 sec. The other meaning could be S is a vector signal with 10 elements. The first element is 3 all the time, the second element is 4 all the time, etc. The way you put S in a constant block makes it take the latter meaning. Is that what you really want?
カテゴリ
ヘルプ センター および File Exchange で Sources についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!