Minimum Block from Simulink

Hi there,
If I had the following vector:
[2.34 50.3 21.9 1.75 22.8 50.1]
and want to find the minimum value with its index, how can I built it in Simulink please? for the vector above the minimum value is 1.75 and the index is 4.
However, I've tried Minimum block but it seems that it does not meet my requirement. Could you please help with this.
Many thanks, Nadia

6 件のコメント

Azzi Abdelmalek
Azzi Abdelmalek 2013 年 2 月 10 日
In simulink, what the vector [2.34 50.3 21.9 1.75 22.8 50.1] is representing?
Nadia
Nadia 2013 年 2 月 10 日
Hi Azzi, thanks for your reply.
Actually, this vector is imported from MATLAB and it represents the input signal of my model design.
Azzi Abdelmalek
Azzi Abdelmalek 2013 年 2 月 10 日
What block are you using to import this vector, constant block or from workspace block, or from file?
Nadia
Nadia 2013 年 2 月 10 日
from workspace block
Azzi Abdelmalek
Azzi Abdelmalek 2013 年 2 月 10 日
Post the setting of your from workspace block
Nadia
Nadia 2013 年 2 月 10 日
sample time: 1
Interpolate data is active high Form output after data value by : Extrapolation

サインインしてコメントする。

 採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2013 年 2 月 10 日
編集済み: Azzi Abdelmalek 2013 年 2 月 16 日

0 投票

If your vector comes from a constant block, for example, you can use matlab function block where you will put a code below:
function [min_value,index]=fcn(v)
[min_value,index]=min(v)
%

9 件のコメント

Azzi Abdelmalek
Azzi Abdelmalek 2013 年 2 月 10 日
Notice that I've added 1 to your vector, it correspond to a time stamp
Nadia
Nadia 2013 年 2 月 10 日
much appreciated your help. just a question please, if the vector had some negative number does this design work?
Azzi Abdelmalek
Azzi Abdelmalek 2013 年 2 月 10 日
編集済み: Azzi Abdelmalek 2013 年 2 月 10 日
Yes it should work.
Nadia
Nadia 2013 年 2 月 10 日
If I had a 4 vectors each has one number, like v1= 25.4 ; v2= 56.3 ; v3=60.3 ; v4=12.55 ;
How do I find the min and its index in this case?
Nadia
Nadia 2013 年 2 月 16 日
For the Matlab function you've posted above, Could vector v be many vectors? I mean the input of the Matlab function is many inputs rather than just one?
Azzi Abdelmalek
Azzi Abdelmalek 2013 年 2 月 16 日
What do you mean? That if v can change every step time, yes but you should change your input source
Nadia
Nadia 2013 年 2 月 17 日
Yes, if v is changing every step time.
Do I need to change the input source manually?
Azzi Abdelmalek
Azzi Abdelmalek 2013 年 2 月 17 日
編集済み: Azzi Abdelmalek 2013 年 2 月 17 日
No, If you want for example the sequences
2 3 4 at 0s
5 6 7 at 1s
8 9 10 at 2s
2 3 9 at 3s
Then in from workspace block set data to x with
x=[0 2 3 4
1 5 6 7
2 8 9 10
3 2 3 9]
In this case, the sample time should be 1s and stop time 3s
Nadia
Nadia 2013 年 2 月 18 日
have you tried that in Simulink please?

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Community Treasure Hunt

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

Start Hunting!

Translated by