Borrar filtros
Borrar filtros

Averaging multiple structures of different lengths

1 visualización (últimos 30 días)
Marisa Mulvey
Marisa Mulvey el 18 de Feb. de 2022
Comentada: Voss el 18 de Feb. de 2022
Hello,
Here is my error message:
Error using horzcat
Dimensions of arrays being concatenated are not consistent.
Error using sum
Dimension argument must be a positive integer scalar, a vector of unique positive integers, or 'all'.
Error in mean (line 127)
y = sum(x, dim, flag) ./ mysize(x,dim);
Here is the script through which I am receiving this message:
a=calc_splitbelt('CSB_YA001_control0008', slowleg)
b=calc_splitbelt('CSB_YA001_control0009',slowleg)
(This produces a as a 1x1 with 14 fields, and b as a 1x1 structure with 14 fields).
Then, I want to take the average StepLengthSym (one of the fields) of both a and b, so my script continues with
c=[a.StepLengthSym b.StepLengthSym]
Avgc=mean(c)
a.StepLengthSym and b.StepLengthSym are different lengths, which I know is what is producing the horzcat error.
Is there a way I can edit this to make it so that I am able to take the average StepLengthSym for both a and b even though those fields are different lengths? TIA

Respuesta aceptada

Voss
Voss el 18 de Feb. de 2022
This will combine a.StepLengthSym and b.StepLengthSym into a single column vector c that you can then take the average of:
c = [a.StepLengthSym(:); b.StepLengthSym(:)];
Avgc = mean(c);
  4 comentarios
Marisa Mulvey
Marisa Mulvey el 18 de Feb. de 2022
Yes just did! Thanks
Voss
Voss el 18 de Feb. de 2022
Thank you! I appreciate it

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

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

Productos


Versión

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by