Borrar filtros
Borrar filtros

Detect changes between specific values in a tall array

2 visualizaciones (últimos 30 días)
Francisco de Juan
Francisco de Juan el 26 de Nov. de 2021
Comentada: Francisco de Juan el 4 de Mzo. de 2024
I need to read through a column in a tall array and detect specific transitions in values.
Let’s say I have a tall vector of integers which indicate the operating modes of a machine. I would like to identify in which lines there are transitions of mode, i.e., 1 ->2, 2 ->4, 4 ->1. The valid transitions are known in advance.
I have tried with movmax, movmin and movmean with some success, but I would like to have a more robust solution. I guess this could be done with matlab.tall.movingWindow and some kind of simple anonymous function, maybe based on diff()?
In practical terms, so that this request can be better understood, I have a tall vector like the first column shown below. I would like to add tall columns to the right marking the initial and final line of each transition.
Tall 1->2 2->4 4->1 1->4
1 0 0 0 0
1 0 0 0 0
1 1 0 0 0
2 1 0 0 0
2 0 0 0 0
2 0 1 0 0
4 0 1 1 0
1 0 0 1 0
Thanks

Respuestas (1)

Divyanshu
Divyanshu el 29 de Feb. de 2024
Hi Francisco,
I have made certain assumptions based on my understanding from the description. Here are the assumptions:
  • You have certain arrays, where 'Tall' array represents various modes of machine while '1->2','2->4' these are logical arrays which indicate whether the machine has made a transition into corresponding mode.
  • The desired output is kind of a vector/array which indicates the rows in which the transition has followed a certain pattern or sequence which is referred as 'Valid Transition'
You can refer the following sample MATLAB script which gives a 'Valid' column vector with values '1' corresponding to rows which have followed the pattern:
Tall = [1;1;1;2;2;2;4;1];
One_Two = [0;0;1;1;0;0;0;0];
Two_Four = [0;0;0;0;0;1;1;0];
Four_One = [0;0;0;0;0;0;1;1];
One_Four = [1;0;0;0;0;0;1;0];
Valid = [0;0;0;0;0;0;0;0];
t = [Tall,One_Two,Two_Four,Four_One,One_Four];
for i=1:height(Tall)
% lets assume 1->2,2->4,4->1 is valid transition.
cond1 = islogical(One_Two(i));
cond2 = islogical(Two_Four(i));
cond3 = islogical(Four_One(i));
if(cond1 && cond2 && cond3)
Valid(i) = 1;
else
Valid(i) = 0;
end
end
t = [t Valid];
Moreover, I have just checked that certain transitions like '1->2, 2->4 ' are done and have not considered the order, for which you can add more conditions as per the use-case and requirement.
  1 comentario
Francisco de Juan
Francisco de Juan el 4 de Mzo. de 2024
Thank you for taking the time to respond to my question, even after so much time has passed.
However, I'm not entirely sure if I have been understood correctly. I was referring to MATLAB tall arrays, which are arrays with more rows than can fit in memory. Results are evaluated only when you request them explicitly using gather. Therefore, I don't believe that "height(Tall)" can be used, for example.

Iniciar sesión para comentar.

Categorías

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

Etiquetas

Productos


Versión

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by