フィルターのクリア

Delete/Extract values from nested cell arrays

2 ビュー (過去 30 日間)
ErikaZ
ErikaZ 2019 年 7 月 11 日
編集済み: ErikaZ 2019 年 7 月 13 日
I have cell array X (see attachment) which is a {1x3}->{1x2}->{2x2}->{1x10}-> (sizes ranging from 5 to 27)
From the inner array, I need to extract/keep the first, middle and last value.
For example, for the attached X:
CPClear_angle{1, 1}{1, 1}{1, 1}{1, 1}
-10.4805997230720 -8.45914496472814 -6.90173932281437 -6.67445150097098 -5.60467260957554 -1.40582560357418
Keep the values: -10.4805997230720 -6.90173932281437 -1.40582560357418 and transpose them so it results in a inner array of 3x10 for all.
I do want to keep the {1x3}->{1x2}->{2x2} arragement because each cell is a different group type.
For a single array, the code below extracts the values I need
x=x(:,[1,ceil(end/2),end])
but I dont know how to apply it to the nested cells.
Thanks.

採用された回答

ErikaZ
ErikaZ 2019 年 7 月 13 日
編集済み: ErikaZ 2019 年 7 月 13 日
Using ncellfun from File Exchange
CPClear=ncellfun(@transpose,CPClear_angle);
CPClear=ncellfun(@cell2mat, CPClear,3);
CPClear=ncellfun(@keepCP, CPClear,3);
and function
function [ m ] = keepCP( x )
m=x([1,ceil(end/2),end],:);
end

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMultidimensional Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by