How can I convert a n*m matrix with its typical form to a linear form of 1*(n*m) one with comma between all elements and semicolon after each row is finished?

조회 수: 3 (최근 30일)
assume that i have a matrix A that
A= [1 2 3
4 5 6
7 8 9]
i want to reach matrix B in the way below:
B= [1,2,3;4,5,6;7,8,9]
so I want to know that is it possible in matlab by any function ?
  댓글 수: 3
Jan
Jan 2022년 6월 12일
A= [1 2 3
4 5 6
7 8 9]
A = 3×3
1 2 3 4 5 6 7 8 9
B= [1,2,3;4,5,6;7,8,9]
B = 3×3
1 2 3 4 5 6 7 8 9
isequal(A, B)
ans = logical
1
So currently it is not clear, what you want to achieve and answering the question requires bold guessing.
Farzaneh Kia
Farzaneh Kia 2022년 6월 12일
편집: Farzaneh Kia 2022년 6월 12일
because i have a written code in which i have to make my input matrix just like that in a linear array in command window in order to it work for me

댓글을 달려면 로그인하십시오.

답변 (2개)

Fangjun Jiang
Fangjun Jiang 2022년 6월 9일
mat2str() but the output is a string

Voss
Voss 2022년 6월 11일
"1*(n*m)"
A= [1 2 3
4 5 6
7 8 9];
B = reshape(A,[1 size(A)])
B =
B(:,:,1) = 1 4 7 B(:,:,2) = 2 5 8 B(:,:,3) = 3 6 9
?
  댓글 수: 1
Farzaneh Kia
Farzaneh Kia 2022년 6월 12일
편집: Farzaneh Kia 2022년 6월 12일
Thank you very much . actually i need each row of my basic matrix stay on next row in a linear way

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by