How to rename array layer number or iteration no.

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 件のコメント

Guillaume
Guillaume 2016 年 1 月 27 日
Indexing in matlab starts at 1. You don't have a choice.
Triveni
Triveni 2016 年 1 月 27 日
Is it not possible to copy array(1:5) to (6:10) ?? or by any other process it could be rename??
Guillaume
Guillaume 2016 年 1 月 27 日
Well, you can always pad the array with 5 rows of zeros, but honestly I don't see the point.
An index is not a name.
Triveni
Triveni 2016 年 1 月 27 日
In case of zeros.
layer = zeros(1,9,10);
can we allocate/fill values of layer(:,:,1) to layer(:,:,5)?. Is it not possible to refill the values from next loop it should be layer(:,:,6) to layer(:,:,10)??
Triveni
Triveni 2016 年 1 月 27 日
I have edited question....please see again

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

 採用された回答

Andrei Bobrov
Andrei Bobrov 2016 年 1 月 27 日
編集済み: Andrei Bobrov 2016 年 1 月 28 日

1 投票

С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 件のコメント

Triveni
Triveni 2016 年 1 月 27 日
I have edited question....please see again
Andrei Bobrov
Andrei Bobrov 2016 年 1 月 28 日
I'm edited my answer

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeDeep Learning Toolbox についてさらに検索

製品

タグ

質問済み:

2016 年 1 月 27 日

編集済み:

2016 年 1 月 28 日

Community Treasure Hunt

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

Start Hunting!

Translated by