AND between vectors element

17 ビュー (過去 30 日間)
Victor Vanni
Victor Vanni 2013 年 12 月 14 日
編集済み: Azzi Abdelmalek 2013 年 12 月 14 日
Hi, everyone.
I have, in simulink, a matrix that I need to separate each line into vectors I would like to AND the elements from each vector.
e.g.:
Matrix:
1 0 0 1 0 1 -> V1
0 0 1 0 0 1 -> V2
1 1 1 1 1 1 -> V3
for each vector I gotta AND the elements, for V1 the result will be 0, for V2 it will be 0 and for V3 it would be 1.
There is a simple way to do this? I know that I can get the vectors from n Submatrix blocks for a matrix with n column.
I need to put all the values into a vector. eg: [AND(V1) AND(V2) AND(V3)] = [0 0 1], so I need to store those values.
edited:
In short: I need to do the follow in Simulink without Matlab Function block:
Output = all(Input,2)
Where "Input" is my matrix.

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2013 年 12 月 14 日
編集済み: Azzi Abdelmalek 2013 年 12 月 14 日
A=[1 0 0 1 0 1
0 0 1 0 0 1
1 1 1 1 1 1 ]
all(A,2)
  5 件のコメント
Azzi Abdelmalek
Azzi Abdelmalek 2013 年 12 月 14 日
You can simplify your task, instead of using 10 columns, you can use 4 rows with minmax block set to min, because for logical numbers
and(a,b) is equal to min(a,b)
Azzi Abdelmalek
Azzi Abdelmalek 2013 年 12 月 14 日
編集済み: Azzi Abdelmalek 2013 年 12 月 14 日
Also, if you have a DSP system toolbox, you can use a Matrix product block set to row product, because
and(a,b) is equal to a*b

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

その他の回答 (0 件)

カテゴリ

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

製品

Community Treasure Hunt

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

Start Hunting!

Translated by