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.

 Respuesta aceptada

Azzi Abdelmalek
Azzi Abdelmalek el 14 de Dic. de 2013
Editada: Azzi Abdelmalek el 14 de Dic. de 2013

0 votos

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

5 comentarios

Victor Vanni
Victor Vanni el 14 de Dic. de 2013
Editada: Victor Vanni el 14 de Dic. de 2013
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 el 14 de Dic. de 2013
Editada: Azzi Abdelmalek el 14 de Dic. de 2013
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 el 14 de Dic. de 2013
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 el 14 de Dic. de 2013
Editada: Azzi Abdelmalek el 14 de Dic. de 2013
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

Iniciar sesión para comentar.

Más respuestas (0)

Productos

Preguntada:

el 14 de Dic. de 2013

Editada:

el 14 de Dic. de 2013

Community Treasure Hunt

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

Start Hunting!

Translated by