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일

0 개 추천

A=[1 0 0 1 0 1
0 0 1 0 0 1
1 1 1 1 1 1 ]
all(A,2)

댓글 수: 5

Victor Vanni
Victor Vanni 2013년 12월 14일
편집: Victor Vanni 2013년 12월 14일
Thanks for your quick answer!
That's perfect for matlab, exactly what I want, but I need this into simulink. Is there something in simulink that do this?
Azzi Abdelmalek
Azzi Abdelmalek 2013년 12월 14일
편집: Azzi Abdelmalek 2013년 12월 14일
What is the size of your output in simulink and why without Matlab function block? If you have problems with Matlab function block you can use Interpreted Matlab Function block
Victor Vanni
Victor Vanni 2013년 12월 14일
If the input size is m lines per n columns, then my output is m lines per 1 column.
In my model I'm testing a 4x10 matrix, so the result will be a 4x1. I already did it in the hard way with 10 submatrix block, one per column, and ANDing all columns matrix.
I was just wandering if there is an easy way to do with some specific block.
I cannot use those Matlab Function block because I'm developing a dedicated hardware model and makes no sense to use those functions, since a dedicated hardware doesn't do functions...
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개)

카테고리

도움말 센터File Exchange에서 Matrix Operations에 대해 자세히 알아보기

제품

질문:

2013년 12월 14일

편집:

2013년 12월 14일

Community Treasure Hunt

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

Start Hunting!

Translated by