I have a lattice (square array) mapped to an array of cells, how could I make it so that if I swap two array elements I have also swapped the cells mapped to those elements?
I would really appreciate all suggestions.
Thank you.
The Cells
l=cell(1,10000);
for i=1:10000
l{i}=[randi(10), randi([0,2])];
end
the array
lattice=1:10000;
map=containers.Map(lattice,l);
lattice=reshape(lattice,100,100)';
now say I want to swap elements 1 and 2 in the array eg lattice([1 2])=lattice([2 1])
I also want this to swap the mapped cells so that l{2} is now l{1} and vice versa.
Any Ideas?
你知道处理 ?
[l{1}, l{2}] = deal(l{2}, l{1});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.