changing the cell values

2 ビュー (過去 30 日間)
Mahmoud Zeydabadinezhad
Mahmoud Zeydabadinezhad 2016 年 8 月 12 日
編集済み: Azzi Abdelmalek 2016 年 8 月 12 日
Hi all, I have a cell array of size 1000x1. Each cell array itself is a 1x4 double variable. How can I change all the third components? lets say something like this C{:}(1,3) = 0.
Thank you!

回答 (2 件)

Azzi Abdelmalek
Azzi Abdelmalek 2016 年 8 月 12 日
A = arrayfun(@(x) randi(10,1,4),1:5,'un',0) % ---Example-----
B=cellfun(@(x) [x(1:2) 0 x(4)],A,'un',0)

Azzi Abdelmalek
Azzi Abdelmalek 2016 年 8 月 12 日
編集済み: Azzi Abdelmalek 2016 年 8 月 12 日
A = arrayfun(@(x) randi(10,1,4),1:5,'un',0)
B=cellfun(@(x) strrep(x,x(3),0),A,'un',0)
celldisp(B)
If the cells content are 2D Matrices
A = arrayfun(@(x) randi(10,6,4),1:5,'un',0)
B=cellfun(@(x) reshape(strrep(x,x(2,3),0),size(x)),A,'un',0)
celldisp(B)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by