How do I use 'ErrorHandler' in arrayfun?
Mostrar comentarios más antiguos
x = arrayfun(@(x) mean(x.Num(1:20,3)), Struct, 'UniformOutput', false)
Struct is a 1x45 structure containing a field called Num, which is an array of integers.
I want to take the mean of the first 20 numbers in the third column pf each of the 45 Num fields, but the problem is that a few of the Num fields have fewer than 20 rows. So when I try to run this, Matlab gives me an error saying "Index exceeds matrix dimensions"
How can I use the ErrorHandler to make the mean = 0 when Num has fewer than 20 numbers in the third column?
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Workspace Variables and MAT Files en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!