Replace value from cell from particular index

I got two 3 x 3 sub-matrix from mat2cell
cell1=[1 1 1; 1 1 1; 1 1 1];
cell2=[0 0 0; 0 0 0; 0 0 0];
i want to replace value from cell1 index (2,2) with cell2 index(2,2)
cellresult=[1 1 1; 1 0 1; 1 1 1];
Thanks

 採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2016 年 4 月 10 日

0 投票

cell1=[1 1 1; 1 1 1; 1 1 1];
cell2=[0 0 0; 0 0 0; 0 0 0];
ii1=[2 2]
ii2=[2 2]
cell1(ii1(1),ii1(2))=cell2(ii1(1),ii1(2))

2 件のコメント

Stef
Stef 2016 年 4 月 10 日
Thanks for the answer , but how to save the
cell1(ii1(1),ii1(2))=cell2(ii1(1),ii1(2))
into new variable like cellresult or cell3
I want to loop the cellresult into sub matrix and then using cell2mat to create new matrix
Stef
Stef 2016 年 4 月 11 日
cell1{i+1,j+1}(2,2)=cell2{i+1,j+1}(2,2)
works for me , Thanks for the answer

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

その他の回答 (0 件)

カテゴリ

質問済み:

2016 年 4 月 10 日

コメント済み:

2016 年 4 月 11 日

Community Treasure Hunt

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

Start Hunting!

Translated by