A = randi(100,1,8); % Some array that I want to index into.
B = {[1;2;3];[4;5];[6];[7;8]}; % Cell array with indices.
%I want to index B into A to get:
C = {[A(1);A(2);A(3)];...;[A(7);A(8)]}

 채택된 답변

Guillaume
Guillaume 2017년 2월 8일

1 개 추천

cellfun(@(b) A(b), B, 'UniformOutput', false)

추가 답변 (0개)

카테고리

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

질문:

2017년 2월 8일

답변:

2017년 2월 8일

Community Treasure Hunt

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

Start Hunting!

Translated by