0
votes

I have a binary file that I am trying to read in. Within the binary is numerical values of 70 variables. The variables has a various number of columns and rows. In general they look like X(n,1) , Y(n+2,1) , Z(n+2,m) , and L(n,m).

My thought was to read in the file as a vector of values and and then reshape it but I don't think I can reshape in a concise way it because the number of rows is not constant.

Any guidance would be greatly appreciated. Thanks.

1

1 Answers

1
votes

It is possible. Assume you have your vector already read:

X=1:17
%dimensions you want First cell 2x2, second cell 3x3, third cell 1x4:
dims=[2,2;3,3;1,4]

Reshaping

%get number of elements per cell
elements=prod(dims,2);
%split
F=mat2cell(X(:),elements)
%reshape each element
result=arrayfun(@(x)(reshape(F{x},dims(x,1),dims(x,2))),1:size(dims,1),'uni',false)