フィルターのクリア

access to matrix inside a cell array

3 ビュー (過去 30 日間)
Sahar Pordeli Behrouz
Sahar Pordeli Behrouz 2019 年 6 月 6 日
回答済み: Walter Roberson 2019 年 6 月 6 日
Hi. I have a 1*100 cell array. Each cell inside this cell array contains a matrix with different numbers of rows but all have one column . I want to compare numbers in each row with a threshold(0.5) and get zero if the number is less than 0.5 and get 1 if it is equal or bigger than 0.5. I wrote below code but it gives me 1 and zero just for each cell not each row of the matrix. Can you please help me ? I think it is relatet to nested cell arrays and indexing issue.
load('maximum_number.mat')
A=maximum_number;
T = { }; %want to get only 1 and 0
for i = 1 :size(A,2)
if A{i}>=0.5
T{i} = 1;
else
T{i} = 0;
end
end

採用された回答

Walter Roberson
Walter Roberson 2019 年 6 月 6 日
cellfun(@(V) V>=0.5, YourCellArray, 'uniform', 0)

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Type Identification についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by