我想要做
myCellArray = myCcellArray{indices}
Run Code Online (Sandbox Code Playgroud)
其中indices只是0s和1s,元素数与行数相同myCellArray,但不起作用.我该怎么办?
Pra*_*ian 12
您需要使用括号而不是花括号来进行索引.
>> arr = cell(2,2);
>> arr{1,1} = magic(4);
>> arr{1,2} = 'Hello';
>> arr{2,1} = 42;
>> arr{2,2} = pi;
>> arr
arr =
[4x4 double] 'Hello'
[ 42] [3.1416]
>> idx = logical(zeros(2,2));
>> idx(1,1) = true;
>> idx(2,2) = true;
>> arr(idx)
ans =
[4x4 double]
[ 3.1416]
Run Code Online (Sandbox Code Playgroud)