for loop through a cell array
11 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I have a 2001x1 cell array containing the data from 2001 .csv files. Each cell in the array contains the data for 1 time step of a experiment run.
I want to write a for loop that can loop through each of the cells in the array and tell me which particles have a x-velocity of 0. Would anybody be able to give me a starting point?
%in the first cell of the cell array 'particle data', if the data in column 2 (x-velocity) is 0, display 'out'
%record the total number of 'out' particles in each cell of the array
%repeat for all 2001 cells in the cell array
0 comentarios
Respuestas (1)
KSSV
el 19 de Nov. de 2020
If A is your cell array, you can access the cell suing A{1}, A{2}, ... A{i},..etc.
for i = 1:length(A)
A{i}
end
Also have a look on cell2mat where you can convert the cell into a matrix and access the elements. Also have a look on vertcat. You can get the indices of elements/ x velocity as zero using:
idx = a==0 ;
a(idx)
0 comentarios
Ver también
Categorías
Más información sobre Loops and Conditional Statements 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!