Sorting data by ascending at sampled points, and using 1-D Lookup table to select highest OR lowest value.

조회 수: 2 (최근 30일)
In my Simulink model; at every point of triggered sampling, I have 4 voltages which are measured at the same time and must be sorted into ascending order (lowest measured voltage value up to highest measured voltage value). Afterwards I want to select the highest measured value out of the 4, or the lowest measured value out of the 4.
I'm certain it is the 1-D lookup table and sort blocks which are required to be used, but there must be others as well, but I am not sure which ones? What command(s) is required to select the highest or lowest values?
EG:
Measured Values: [ 2 4 3 1]
Then to place into ascending order:
[ 1 2 3 4]
Then a command to select highest or lowest:
highest = 4
lowest = 1
I hope it is clear, it's quite straight forward I presume and I hope, I just haven't got the experience using Simulink, and the documentation doesn't really help.
Many thanks!
  댓글 수: 2
dpb
dpb 2013년 7월 20일
Do you really have to have them sorted or simply select the min/max?
Simon Fletcher
Simon Fletcher 2013년 7월 22일
Yes they need to be sorted, this is because this data is to be used in another if statement; which determines if it is possible to use the lowest/highest data, if not then the 2nd highest/lowest data is to be used, then if not the 2nd, the 3rd is used and so on. Thanks for the reply.

댓글을 달려면 로그인하십시오.

답변 (1개)

dpb
dpb 2013년 7월 22일
OK, I "know nuthink" as per Sgt Schultz specific on Simulink but afaik you can use Matlab functions as blocks. To my surprise I didn't find a SORT block in the online doc's so you could use the Matlab sort() function. It returns the input vector sorted so the given outputs will be in a specific location. If you need the original position(s), it also has a second optional output that is the index vector of locations in the original.

카테고리

Help CenterFile Exchange에서 Shifting and Sorting Matrices에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by