Extracting and arranging nested data within cell array

时间:2015-11-12 11:53:27

标签: matlab netcdf cdf

I need to ingest a CDF (common data format) file into MATLAB. I have used the [cdfread][1] command for this purpose. An image of my output is attached below:

When I open data_import, columns 4 and 5 are in a particular 3 x 1 format (as shown in data_import(1,4)).

My question is: Is there a simple way to extract the data for each cell in column 4, such that for the 2nd row in data_import(1,4), it gets inserted as a new column (i.e. column 5) in the original data (data_import)? Similarly, 3rd row in data_import(1,4) should be inserted as a new column (column 6) in the original data (data_import). This procedure should also be repeated in the original Column 5 data which also has a similar 3 x 1 structure within each cell.

I hope I'm not being too vague in what I am describing, but I'm really not sure what I'm supposed to do regarding the commands to call for the operation. Thank you in advance.

1 个答案:

答案 0 :(得分:0)

您想要的最终输出包含由这些单元格组成的列,这些单元格从3 x 1数组转换为1 x 3单元格数组,然后连接每一行。首先使用"错误的方式进行连接更容易#34;然后转置最终结果:

data_import = [data_import(:,1:3) num2cell([data_import{:,4}; data_import{:,5}]') data_import(:,6:end)];