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?
답변 (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.
카테고리
도움말 센터 및 File Exchange에서 Data Type Conversion에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!