필터 지우기
필터 지우기

Suppose i have a matrix (2x4) A=[1 2 3 4;5 6 7 8] and i want to change it into this matrix [1 2;3 4;5 6;7 8]. How to do that?

조회 수: 4 (최근 30일)
A= [1 2 3 4;5 6 7 8]
Output needed
B= [1 2;3 4;5 6;7 8]

채택된 답변

Stephen23
Stephen23 2023년 6월 17일
편집: Stephen23 2023년 6월 17일
When using MATLAB you will do these kind of things quite often. Understand the order of data stored in memory:
A = [1,2,3,4;5,6,7,8]
A = 2×4
1 2 3 4 5 6 7 8
B = reshape(A.',2,4).'
B = 4×2
1 2 3 4 5 6 7 8

추가 답변 (2개)

John D'Errico
John D'Errico 2023년 6월 17일
편집: John D'Errico 2023년 6월 17일
help transpose
help reshape
Essentially, you need to learn how elements are stored in a matrix. You need to learn to manipulate the shapes of the matrices you will work with. If you don't understand this, well, then it is time to learn!

Image Analyst
Image Analyst 2023년 6월 17일
@Payel this is super basic. You're not going to get very far, very fast if you have to ask Answers volunteers every time you want to do something as simple as this. You need to learn it yourself.
To learn other fundamental concepts, invest a quick 2 hours of your time here:

카테고리

Help CenterFile Exchange에서 Image Data Workflows에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by