This is an updated version of the question Merge two arrays Matlab
Suppose the two arrays are now
A1 = [x1 y1
x2 y2
x3 y3
0 0
0 0
0 0
0 0
0 0
]
and
A2 = [a1 b1
a2 b2
a3 b3
a4 b4
0 0
0 0
0 0
]
Now, how to merge A1 and A2 in the shortest way, such that
A = [x1 y1
x2 y2
x3 y3
a1 b1
a2 b2
a3 b3
a4 b4
0 0]
The earlier answer was correct and it removes all the zeros. But how to achiev this in the shortest way by indexing , similar to the previous answer?
Update :
This is what I tried Using the answer from the previous question
A=[A1(max(A1')>0,:);A2(max(A2')>0,:)]
A = padarray(A,[size(A1,1) - size(A,1) 0],'post')
It is pretty trivial, but as I have mentioned in my question clearly, is there an one line answer or a command that can achieve this like the previous question? My main aim is to expand my knowledge base on how to effectively use the indexing advantage of matlab and act as a guide for others as well who will come across this question, with many suggestions it may have.
Thanks, LN