Accessing cell array contents
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
I have a one-dimensional cell array where each element of the array contains a timetable with identical format. Is there a direct way of creating a vector that contains the last element of one specific variable in each timetable (without looping)?
For example, something like:
CellArray{:}.Variable(end)
2 comentarios
Rik
el 30 de Jun. de 2022
You're welcome. If either answer solved your problem, feel free to mark it as accepted answer. If the other was helpful as well, consider giving it an upvote.
Respuesta aceptada
Rik
el 30 de Jun. de 2022
Editada: Rik
el 30 de Jun. de 2022
No. You could use cellfun, but that will only hide the loop. Using a loop directly tends to have better efficiency.
But don't worry: loops are not as bad as you might think (especially if you pre-allocate the output). They are only bad when there isn't a builtin equivalent that operates on the entire array.
1 comentario
Más respuestas (1)
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!