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개)

Adam
Adam 2017년 7월 11일
편집: Adam 2017년 7월 11일

0 개 추천

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

Elaine Carroll
Elaine Carroll 2017년 7월 11일
Yes, you are totally correct, I already found it myself. Thanks!

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Data Type Conversion에 대해 자세히 알아보기

질문:

2017년 7월 11일

댓글:

2017년 7월 11일

Community Treasure Hunt

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

Start Hunting!

Translated by