Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

How to calculate the number value did appear continuously in column?

2 visualizaciones (últimos 30 días)
Mantas Vaitonis
Mantas Vaitonis el 6 de Jul. de 2018
Cerrada: MATLAB Answer Bot el 20 de Ag. de 2021
Hello Everyone,
I have the following code that works fine with vectors. However I can’t figure out how to do the same on arrays for columns. The thing I want to achieve is to count how many times same number appears in a column continuously. One more thing, would it be possible to avoid cell arrays? Because I work with gpu and cell arrays are slow on gpu. Here is the code:
x = [4 4 4 1 1 1 5 5 0 0 0 7 7 7 1 1 1 1];
[v,h]=size(x);
ind=find(diff(x,1,2)) ;
di = [ind h] - [0 ind];
b = arrayfun(@(x) x-1:-1:0, di , 'un',0);
d=cellfun(@(x) fliplr(x),b,'un',0);
y = cat(2,d{:});

Respuestas (0)

La pregunta está cerrada.

Community Treasure Hunt

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

Start Hunting!

Translated by