How to get cell array of values by index
Mostrar comentarios más antiguos
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?
Respuestas (1)
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 comentario
Elaine Carroll
el 11 de Jul. de 2017
Categorías
Más información sobre Data Type Conversion 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!