MATLAB Answers

How can I change this 3-D array(2000,21,80) to 4-D array(1000,20,21,80)?

15 views (last 30 days)
楠 赵
楠 赵 on 25 Dec 2020
Commented: Walter Roberson on 25 Dec 2020
Hi,all !How can I change one 3-D array(2000,21,80) to 4-D array(1000,20,21,80)?

  0 Comments

Sign in to comment.

Answers (1)

the cyclist
the cyclist on 25 Dec 2020
Edited: the cyclist on 25 Dec 2020
Did you mean (1000,2,21,80)? If so, then you can use the reshape command:
output = reshape(x,[1000,2,21,80]);
where x is your input array.
If that is not what you meant, then you'll need to explain how you want to generate the greater number of elements in the output array.

  3 Comments

楠 赵
楠 赵 on 25 Dec 2020
Sorry, I do want a (1000,2,21,80) array. But I wonder whether I can use reshape function? since I need 1-D and 2-D in present sequence. whether reshpe would change the item sequence in 1-D and 2-D?
the cyclist
the cyclist on 25 Dec 2020
You didn't give any information about how you wanted the elements from the input array arranged in the output array. We can't suggest how to do what you want, if you don't tell us.
Walter Roberson
Walter Roberson on 25 Dec 2020
reshape never changes the order in memory. A column of 2000 would reshape to two adjacent rows of 1000, first 1000 elements of the column then the second 1000.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!

Translated by