フィルターのクリア

Find and replacing elements in cell array

96 ビュー (過去 30 日間)
Yaameen
Yaameen 2015 年 6 月 3 日
編集済み: Fiction 2015 年 6 月 3 日
I have a 1x10 cell which is generated using a loop. I would like to check each cell array (ex: F{1,1}, F{1,2}) for a specific numerical number and then replace those numbers by zero. How can I do that?

採用された回答

Fiction
Fiction 2015 年 6 月 3 日
編集済み: Fiction 2015 年 6 月 3 日
Assuming your cell is made up of vectors. Every cell{i} is a numerical vector itself.
this code should work:
for i=1:10
a=cell{i};
for j=1:length(a)
if a(j)==1||a(j)>25 %(example conditions put your own)
a(j)=0;
end
cell{i}=a;
end
end
Hope it helps.
PS. this also does it without using double loop:
for i=1:10
a=cell{i};
ind=find(a==1|a>25) %(example conditions put your own)
a(ind)=0
cell{i}=a;
end

その他の回答 (0 件)

カテゴリ

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

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by