How to cut and reshape values?

out =
Columns 1 through 5
90 90 -45 0 0
90 90 -45 0 0
90 90 -45 0 0
90 90 -45 0 45
90 90 0 0 45
90 -45 0 0 45
Columns 6 through 9
45 45 0 -45
45 45 -45 0
45 0 -45 45
45 0 -45 0
45 0 -45 -45
45 0 -45 90
i want to reshape it into layer
layer = reshape(layer',size(layer,2),1,size(layer,1))
but i'm getting vertical...but i need horizontal
& I want only last 5 layer Means
layer(:,:,1) = [90 90 -45 0 0 45 45 -45 0];
layer(:,:,2) = [90 90 -45 0 0 45 0 -45 45] and so on....

 Accepted Answer

Andrei Bobrov
Andrei Bobrov on 26 Jan 2016
Edited: Andrei Bobrov on 26 Jan 2016
layer1 = reshape(layer(2:end,:)',1,size(layer,2),5)

5 Comments

I want only last 5 layers
corrected
I think that is first five rather than last five.
Hey Walter! I agree with you, I corrected the answer.
layer1 = reshape(layer(2:end,:)',1,size(layer,2),(size(layer,1)-1));
Thanks it's works for all type.

Sign in to comment.

More Answers (1)

layer = permute(out, [2 3 1])

3 Comments

I want only last 5 layers
layer = permute(out(end-4:end,:), [2 3 1])
Andrei's answers is works. Your code I've tried earlier too.... it's giving vertical...& i need horizontal.
Thank you Sir....You help lot not only me..everyone.

Sign in to comment.

Categories

Find more on MATLAB in Help Center and File Exchange

Tags

Asked:

on 26 Jan 2016

Commented:

on 26 Jan 2016

Community Treasure Hunt

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

Start Hunting!