How to get cell array of values by index

Hello. I'm dealing with a cell data stored in .mat -file. Field S.Name has dimension 1000*1 From that data I extracted indices corresponding to specific Name values, e.g.
IndA1= find(ismember(S.Name,'C'));
IndA2 = find(ismember(S.Name,'D'));
IndA3 = find(ismember(S.Name,'F'));
They have dim = (400*1), (300*1) and (300*1)
Now I need to extract from another field S.A that has dim (1000*100) values by these indices, like that:
A_A1 = Amp(IndA1);
A_A2 = Amp(IndA2); etc
But I obtained answers with dim like (400*1) instead of (400*100) I tried to fix it with smth like A_A1 = A([1:101]), but to no avail. Could you please advice what to do to resolve it?

Réponses (1)

Adam
Adam le 11 Juil 2017
Modifié(e) : Adam le 11 Juil 2017
A_A1 = Amp(IndA1,:);
is what you need if Amp is 2 dimensional and you want to retain the 2nd dimension and apply IndA1 down the first dimension. You seem to keep using different variable/field names throughout your examples in the question though so it isn't 100% obvious what Amp is.

1 commentaire

Elaine Carroll
Elaine Carroll le 11 Juil 2017
Yes, you are totally correct, I already found it myself. Thanks!

Connectez-vous pour commenter.

Catégories

Community Treasure Hunt

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

Start Hunting!

Translated by