Asked by Toni Addison
on 18 Nov 2013

I have a matrix and I am told to split my one column matrix into two equal matrics; For example if D=[1 5 2 4] then my output would be A11=[1 5] A12=[2 4]. I have coded the following function below my issue is my last A12 matrix =[0 0 2 4] instead of just [2 4]. How do I fix this? thanks

[A11,A12,]=SplitMatrix( D ) [r c]=size(D); if r==1 && Mod(c,2)==0 for i=1:r for j=1:c/2 A11(j)=D(i,j) end for j=((c/2+1):c) A12(j)=D(i,j) end end

*No products are associated with this question.*

Answer by Azzi Abdelmalek
on 18 Nov 2013

A11=D(1:2) A12=D(2+1:end)

Toni Addison
on 18 Nov 2013

Opportunities for recent engineering grads.

## 0 Comments