フィルターのクリア

I am trying to index from Cell array

1 回表示 (過去 30 日間)
Kiran Isapure
Kiran Isapure 2022 年 12 月 9 日
編集済み: Imraan Ibrahim 2022 年 12 月 16 日
I have a nested cell array
pos{1X4}
>> {6830X1}{6824X1}{6834X1}{6826X1}{6842X1}{6840X1}{6836X1}{6844X1}{6837X1}{6833X1}
I am trying to index from cell array, but I am getting Unable to use a value of type cell as an index.
position_0{tr} = pos(time_0);
  8 件のコメント
Kiran Isapure
Kiran Isapure 2022 年 12 月 12 日
Both the array are 11, I am still figuring why I am getting this errorr-Index exceeds the number of array elements. Index must not exceed 11.
I am attcahing the Raw here now.
Imraan Ibrahim
Imraan Ibrahim 2022 年 12 月 16 日
編集済み: Imraan Ibrahim 2022 年 12 月 16 日
I've just downloaded the raw data
The 1st cell of both time_0.mat and pos.mat is empty so that would cause a problem.
pos =
1×11 cell array
{0×0 double} {6830×1 double} {6824×1 double} {6834×1 double} {6826×1 double} {6842×1 double} {6840×1 double} {6836×1 double} {6844×1 double} {6837×1 double} {6833×1 double}
time_0 =
1×11 cell array
{0×0 double} {[1002]} {[1002]} {[1002]} {[1002]} {[1002]} {[1002]} {[1002]} {[1002]} {[1002]} {[1002]}
Try the following:
position_0 = cellfun(@(p,t) p(t), pos, time_0, 'UniformOutput', false);
Bear in mind that the 1st index of position_0 will also be empty
position_0 =
1×11 cell array
{0×0 double} {[86.9711]} {[86.9943]} {[87.0181]} {[87.0761]} {[87.0062]} {[87.0405]} {[86.9515]} {[86.9467]} {[87.0836]} {[86.9525]}

サインインしてコメントする。

採用された回答

Imraan Ibrahim
Imraan Ibrahim 2022 年 12 月 9 日
編集済み: Imraan Ibrahim 2022 年 12 月 9 日
It sounds like time_0 is a cell.
time_0 should to be positive integers or logical values
I'm assuming that time_0 is a cell containing an array of indices.
If that is the case, you can try something like:
position_0{tr} = pos([time_0{:}]);

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by