I have a huge 2464 * 2484 matrix that I want to manipulate and make 2684*2684 but I need the new 220 rows to be divided into 5 rows after every 56 rows of original matrix. I am able to think of loop code —
>> A=csvread('InputWIODRaw.csv'); >> A=csvread('InputWIODRaw.csv'); >> B= zeros(5,2684); >> CountryVar = [56:56:2464]; >> for i = 1:44 if i==1 j=1; elseif i>1 j=CountryVar(i-1)+1; end ReorderMatrix(i)= A(j:CountryVar(i),:);Reorder(i) = [ReorderMatrix(i); B];enderror: =: nonconformant arguments (op1 is 1x1, op2 is 56x2684)>> for i = 1:44 if i==1 j=1; elseif i>1 j=CountryVar(i-1)+1; end ReorderMatrix(i) = zeros(56,2684);,2684)= A(j:CountryVar(i),:);parse error: syntax error>>> ReorderMatrix(i) = zeros(56,2684);,2684)= A(j:CountryVar(i),:); ^>> ReorderMatrix(i) = zeros(56,2684);error: =: nonconformant arguments (op1 is 1x1, op2 is 56x2684)
But not sure how to initialize. Is there a better way if not how to rectify this code? Much appreciated
Best Answer