How to rename array layer number or iteration no.
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Triveni
am 27 Jan. 2016
Bearbeitet: Andrei Bobrov
am 28 Jan. 2016
I have an array
layer1 =
90 90 -45 0 0 45 45 0 -45
90 90 -45 0 0 45 45 -45 0
90 90 -45 0 0 45 0 -45 45
90 90 -45 0 45 45 0 -45 0
90 90 0 0 45 45 0 -45 -45
90 -45 0 0 45 45 0 -45 90
layer = reshape(layer1(2:end,:)',1,size(layer1,2),(size(layer1,1)-1));
output
layer(:,:,1) =
90 90 -45 0 0 45 45 -45 0
layer(:,:,2) =
90 90 -45 0 0 45 0 -45 45
layer(:,:,3) =
90 90 -45 0 45 45 0 -45 0
layer(:,:,4) =
90 90 0 0 45 45 0 -45 -45
layer(:,:,5) =
90 -45 0 0 45 45 0 -45 90
I'm calculating other values for layer1 and i want to reshape to layer(:,:,6) to layer(:,:,10)
layer1 =
90 -45 0 0 45 45 0 -45 90
90 -45 0 0 45 45 -45 0 90
90 -45 0 0 45 0 -45 45 90
90 -45 0 45 45 0 -45 0 90
90 0 0 45 45 0 -45 -45 90
-45 0 0 45 45 0 -45 90 90
>
5 Kommentare
Akzeptierte Antwort
Andrei Bobrov
am 27 Jan. 2016
Bearbeitet: Andrei Bobrov
am 28 Jan. 2016
Сan it?
layer1 = circshift(layer1,[0 8]);
or
layer1 = layer1(:,[2:end,1]);
or
p = [90 90 -45 0 0 45 45 0 -45];
idx = fliplr([true, diff(fliplr(p))~=0]);
ii = find(idx);
n = numel(ii);
layer1 = zeros(n,numel(p));
layer1(1,:) = p([2:end,1]);
i1 = fliplr(ii);
for jj = 2:n
layer1(jj,:) = layer1(jj-1,:);
layer1(jj,[i1(jj)-1,end-1]) = layer1(jj,[end-1,i1(jj)-1]);
end
2 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!