Filter löschen
Filter löschen

Conconate arrays horizontally in an automatic manner

1 Ansicht (letzte 30 Tage)
Inti Vanmechelen
Inti Vanmechelen am 28 Apr. 2022
Beantwortet: dpb am 28 Apr. 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

Antworten (1)

dpb
dpb am 28 Apr. 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...

Kategorien

Mehr zu Data Type Identification finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by