从Excel中提取列并将其转换为矩阵中的行

时间:2015-10-19 11:54:24

标签: excel matlab matrix

我从十台测试机器中收集了数据。每个收集的数据是2879x35矩阵。 35列代表变量。棘手的部分是我必须执行统计分析,我需要这些变量在行中。更棘手的部分是每台机器的变量需要堆叠在一起,第二,第三等变量列彼此相邻。 E.g:

machine_1 = 1 2 3 
            4 5 6
            7 8 9

machine_2 = a b c
            d e f
            g h i

我需要什么:

Fat_matrix = 1 4 7 2 5 8 3 6 9
             a d g b e h c f i

我在Excel中有这些数据,标有每一列,我正在使用MATLAB。

1 个答案:

答案 0 :(得分:0)

the basic answer in relation to you question is

machine_1 = [1 2 3 
            4 5 6
            7 8 9]
machine_2 = [10 11 12
            13 14 15
            16 17 18]        

mach1_new= reshape(machine_1,1,9)       
mach2_new= reshape(machine_2,1,9)
[mach1_new' mach2_new']'

follwing beakers comment:

[mach1_new; mach2_new]

provides the same result.

if you want to do it for more, if it contains strings and characters as you show above, or if you want to read it in automatically its more difficult and we would need more information...