Borrar filtros
Borrar filtros

Cell arrays inside a structure array - how to access and perform operations?

10 visualizaciones (últimos 30 días)
Hi,
I have a struct with a number of different fields. Some of these fields have two columns of cell arrays. Each cell array contains differently sized columns:
results.x{1,1} % has size 47x1
results.x{1,2} % has size 36x1
I need to:
1) Compute the mean of each cell.
2) Remove empty cells that might be found
3) Compute the mean of each column of cell arrays inside all fileds.
Not sure if I managed to clearly explain what I'm after. I've added a simplified exmaple file for clarity.
Any suggestion on how to approach this problem?

Respuesta aceptada

David Hill
David Hill el 30 de En. de 2021
I did not put x and t back into a struct.
a=find(ismember(isnan(results.timestamps),[1 1],'rows'),1)-1;%delete rows after
x=results.x(1:a,:);
t=results.timestamps(1:a,:);%does not seem you want to do anything with the timestamps
colmean=[mean(cell2mat(x(:,1))),mean(cell2mat(x(:,2)))];
cellmean=zeros(a,2);
for k=1:a
cellmean(k,1)=mean(x{k,1});
cellmean(k,2)=mean(x{k,2});
end

Más respuestas (0)

Categorías

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

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by