# Manipulating multidimensional array cell elements

5 visualizaciones (últimos 30 días)
Andy Millar el 30 de Mayo de 2017
Respondida: Jan el 2 de Jun. de 2017
I have a 1x9 array with each cell containing a 10000x1 array of data points. I wish to "strip" every cell in the original 1x9 array of values <= 0, most likely by using this operator in conjunction with 'something'=NaN. In the end, there should be a 1x9 array with each cell containing (for example) an 8000x1 array of data points.
AllForce={Fx1(:,2) Fx2(:,2) Fx3(:,2) Fx4(:,2) Fx5(:,2) Fx6(:,2) Fx7(:,2) Fx8(:,2) Fx9(:,2)};
My attempt involves something along the lines of AllForce(AllForce(:)<=0)=[], but I can't seem to figure out what I should replace the "AllForce(:)" part with.
I am open to any suggestions with this problem. Thanks for the help!
##### 2 comentariosMostrar NingunoOcultar Ninguno
Rik el 30 de Mayo de 2017
It may be easiest to convert the entire thing to a matrix, process it, and then convert it back to a cell. That will make things much easier to code and debug IMHO.
Stephen23 el 30 de Mayo de 2017
I second Rik Wisselink's comment: you should always store your data in the simplest array possible that will hold that data, as this always simplifies the processing of that data. On very common mistakes beginners make is to try and write pointlessly complicated code to work around the fact that their data is structured vary badly. In this case it would likely be better to load all of the data into one ND numeric array, and then the processing will be trivial.

Iniciar sesión para comentar.

### Respuestas (2)

Aylin el 1 de Jun. de 2017
You can operate over arrays within a cell array using the cellfun function:
A = cell(1, 9); % Create a 1x9 cell array
A = cellfun(@(arr) rand(10, 1), A, 'UniformOutput', false); % Populate each cell with 10x1 double arrays
B = cellfun(@(arr) arr(arr > 0.5), A, 'UniformOutput', false); % Remove elements <= 0.5
The above example uses cellfun with MATLAB function handle syntax to populate and filter arrays within a cell array.
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

Jan el 2 de Jun. de 2017
C = cell(1, 9);
for k = 1:9
C{k} = Data.(sprintf('Fx%d', k))(:, 2);
end
AllForce = cat(1, C{:});
AllForce = AllForce(AllForce > 0));
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

### Categorías

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

### Community Treasure Hunt

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

Start Hunting!

Translated by