How to print all 1x243 elements of an array in a single row

조회 수: 2 (최근 30일)
Rae Pond
Rae Pond 2018년 6월 6일
답변: Navdha Agarwal 2019년 6월 21일
Greetings
I could really use some guidance
I have a 1x243 array and I would like the values to print all on the same row but multiple columns (e.g. row 1, column A...column Z have output).
Right now the array prints out on the .csv like this:
14-02-TL-C-A-1 1/4/17 67.124263
7.29E+01 7.05E+01 84.4815
6.92E+01 8.75E+01 76.180197
8.69E+01 7.62E+01 87.71914
9.30E+01 8.81E+01 106.408918
1.02E+02 1.09E+02 108.35056
1.08E+02 1.19E+02 124.219392
1.34E+02 1.29E+02 130.762177
I would really like to print it out like this:
A B C D E F G
row 1: 14-02-TL 1/4/17 67.124 7.29 7.05 84.48 6.92
Thank you

답변 (1개)

Navdha Agarwal
Navdha Agarwal 2019년 6월 21일
You can use reshape.
If you have an array of dimensions 1x243, then using the following you can convert it to an array of dimensions 243x1. This will display all the elements of the array in the single row having multiple columns.
B = reshape(A,[243,1]) % generates an array B of dimension 243x1
For more information, you can refer to the documentation of the function reshape

카테고리

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