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

 采纳的回答

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 个评论

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
cell1{i+1,j+1}(2,2)=cell2{i+1,j+1}(2,2)
works for me , Thanks for the answer

请先登录,再进行评论。

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 Logical 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by