Compare arrays in Simulink

13 visualizaciones (últimos 30 días)
Dhruv
Dhruv el 14 de Ag. de 2013
I have two arrays which I would like to compare with each other.
eg. A = [4.1,5.2,7.1] B = [1,2,3,4,5,6,7,8]
I want to be able to say that the following match 4.1->4, 5.2->5, 7.1->7 and then show it in a different array like C = [0,0,0,1,1,1,0]
I have been trying to use For loops but havent managed to solve it as yet. Any suggestions would be useful
*edit
I cannot use a Matlab function block as I need to use it with TargetLink later.
Thanks, Dhruv
  5 comentarios
Friedrich
Friedrich el 14 de Ag. de 2013
Editada: Friedrich el 14 de Ag. de 2013
I guess thats the range. Values between 0 and 2.3 are mapped to 1 and so. However its not clear what hapens with values equal to 2.3. Are those values mapped to 1 or 2?
Dhruv
Dhruv el 14 de Ag. de 2013
I have edited my comment to remove the confusion

Iniciar sesión para comentar.

Respuestas (2)

Azzi Abdelmalek
Azzi Abdelmalek el 14 de Ag. de 2013
A = [4.1,5.2,7.1];
B = [1,2,3,45,6,7,8];
out=zeros(size(B));
out(fix(A))=1
  10 comentarios
Friedrich
Friedrich el 14 de Ag. de 2013
Is a Look-Up-Table supported? If so, this would be what you need together with a For Itterator Subystem.
Dhruv
Dhruv el 19 de Ag. de 2013
I have the possibility of using a Matlab embedded block inside a Stateflow chart.. though I have never used Stateflow.. could you think of it as a possibility to be used in such a case?

Iniciar sesión para comentar.


Chetan Aswathanarayana
Chetan Aswathanarayana el 20 de Ag. de 2013
  1 comentario
Chetan Aswathanarayana
Chetan Aswathanarayana el 20 de Ag. de 2013
https://www.dropbox.com/s/9iqv09tuw061vzj/Array_Compare.zip

Iniciar sesión para comentar.

Categorías

Más información sobre Simulink Functions en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by