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

 Akzeptierte Antwort

Azzi Abdelmalek
Azzi Abdelmalek am 10 Apr. 2016

0 Stimmen

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 Kommentare

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

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Gefragt:

am 10 Apr. 2016

Kommentiert:

am 11 Apr. 2016

Community Treasure Hunt

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

Start Hunting!

Translated by