Simulink: minimum values in vector segments
古いコメントを表示
In Simulink I have a vector, whose elements can be considered as groups. I need to find the minimum value of each group.
For example I have a vector of 20 elements, which can be devided in five segments of four elements each. The result should be a vector of five minimum values (one for each segment). The exact length of the vector and the number of segments are defined by workspace variables and are constant at runtime.
The equivalent matlab code would be this:
for segment = 1:n_segments
segment_length = n_input_elements/n_segments;
result(segment) = min( inputvector(1+(segment-1)*segment_length : 1+segment*segment_length) );
end
I did not manage to use the MinMax block (together with a selector block) to achieve the desired behaviour. Do you have any suggestions how to implement this?
Best regards
回答 (1 件)
Fangjun Jiang
2020 年 6 月 30 日
編集済み: Fangjun Jiang
2020 年 6 月 30 日
1 投票
Use a MATLAB Function block and code similar like this: y=min(reshape(1:20,4,5))
work out the warnings and errors regarding variable size of the data

2 件のコメント
NiFu
2020 年 7 月 1 日
カテゴリ
ヘルプ センター および File Exchange で Sources についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!