# 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?

1 view (last 30 days)
Farzaneh Kia on 9 Jun 2022
Edited: Farzaneh Kia on 12 Jun 2022
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 ?
Farzaneh Kia on 12 Jun 2022
Edited: Farzaneh Kia on 12 Jun 2022
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

Fangjun Jiang on 9 Jun 2022
mat2str() but the output is a string
##### 2 CommentsShowHide 1 older comment
Jan on 12 Jun 2022
Correct. Do you want something else?

Voss on 11 Jun 2022
"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
?
Farzaneh Kia on 12 Jun 2022
Edited: Farzaneh Kia on 12 Jun 2022
Thank you very much . actually i need each row of my basic matrix stay on next row in a linear way