フィルターのクリア

Perform operations on a cell variable

3 ビュー (過去 30 日間)
Anton Sørensen
Anton Sørensen 2020 年 4 月 13 日
コメント済み: Anton Sørensen 2020 年 4 月 13 日
Hi all,
I want to perform operations on a cell variable containing different matrices.
I have a cell variable that have 14 different matrices with different length, ie. 2*130, 2*157, etc.
For each cell, I have to perform the following operation.
c = {P1 P2 P3 P4 P5 P6 P7 P8 P9 P10 P11 P12 P13 P14}; % Each P is a different matrix but they are all 2*x long (ie. 130 or 157)
for i = 1:14
WW = sum(c{i},1)>=median(c{i}),1); & sum(c{i},2) >=median(c{i},2); % Condition, my WW variabel should be 1*14 in size, containing the sum of amount of columns that satisfy the condition
end
I know this is dead wrong, but I just want to give you guys an indication of what I want.
Basically, I need my WW to contain the amount of columns that satisfy the condition mentioned in the code. So WW will be the total amount of rows that satisfy the condition.
I want to find the amount of columns that are larger than the median in both row 1 and 2.
Do anyone have a good solution for this?
Kind regards
Anton

採用された回答

Mehmed Saad
Mehmed Saad 2020 年 4 月 13 日
  5 件のコメント
Anton Sørensen
Anton Sørensen 2020 年 4 月 13 日
編集済み: Anton Sørensen 2020 年 4 月 13 日
Hi again Muhammad,
Do you have an idea on how to fix the following:
c = {P1 P2 P3 P4 P5 P6 P7 P8 P9 P10 P11 P12 P13 P14};
med_1 = cellfun(@median,cellfun(@(x) x(1,:),c,'UniformOutput',false),'UniformOutput',false);
med_2 = cellfun(@median,cellfun(@(x) x(2,:),c,'UniformOutput',false),'UniformOutput',false);
WW =sum(cellfun(@(x) x(1,:),c,'UniformOutput',false)>=med_1) & sum(cellfun(@(x) x(2,:),c,'UniformOutput',false)>=med_2) ;
I keep getting this error message: Undefined function 'ge' for input arguments of type 'cell'.
Thanks.
Anton Sørensen
Anton Sørensen 2020 年 4 月 13 日
Hi again,
I found a solution.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by