Find 2nd Minimum between Input Wheel Speed Signal

1 回表示 (過去 30 日間)
Sagar Patil
Sagar Patil 2021 年 2 月 4 日
コメント済み: Sagar Patil 2021 年 2 月 4 日
I want to find the 2nd Minimum wheel speed out of 4 wheel speeds, as Min-Max block provides highest and lowest value how to find 2nd minimum value.

採用された回答

Alex Alex
Alex Alex 2021 年 2 月 4 日
編集済み: Alex Alex 2021 年 2 月 4 日
Try this code for "matlab function" block.It should work for the same values too and if wheel speed>0.This is not the best solution, but I tried
function [y1, y2] = fcn(a, b, c, d)% input and output viriables
w1 =[a,b,c,d]% array with all input
i=length(w1)% number of input
k=i% number of input for circle
while k>2 &i>0% true while more than 2 non-zero inputs
e=max(w1)% find max from inputs
if w1(i)==e% check max and "input number i"
w1(i)=0% set 0 if input=maх value
k=k-1%set less value with non-zero inputs
i=length(w1)% return i to number of inputs
else
i=i-1% set i for check next "input number i"
end
end
w1=nonzeros(w1)% clear array from zero values
y1=max(w1)% set 1 minimum
y2=min(w1)% set 2 minimum
end

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by