Effacer les filtres
Effacer les filtres

Conconate arrays horizontally in an automatic manner

1 vue (au cours des 30 derniers jours)
Inti Vanmechelen
Inti Vanmechelen le 28 Avr 2022
Réponse apportée : dpb le 28 Avr 2022
Hi,
I have the following matrix:
features_arm.(subjects{q}).(taskname{i}).AccNorm
taskname contains RF1, RF2 & RF3. (reach forward)
I would like to use
horzcat(features_arm.(subjects{q}).RF1.AccNorm,features_arm.subjects{q}).RF2.AccNorm,features_arm.subjects{q}).RF3.AccNorm)
However, not all subjects have RF1, RF2 and RF3 (eg some only have RF1 and RF2).
Would there be an elegant way to conconate the data for all tasks without having to check this manually for each subject?
(I was thinking something in the area of 'RF*', but I am failing to figure something out that works)
Thanks

Réponses (1)

dpb
dpb le 28 Avr 2022
"The MATLAB way" around such problems is to not create sequentially-named variables of the type RFn but use either cell arrays or dynamic field names to write generic code.
See the content of the old MATLAB FAQ Wiki at <FAQ#How_can_I_create_variables_A1.2C_A2.2C....>
There used to be a link in the doc to similar content but they've changed the organization and I now no longer find that so easily...

Catégories

En savoir plus sur Data Type Identification dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by