MATLAB: Adding values in array

index

Hi suppose I have two variable
idx1=
1
2
3
idx2=
4
5
I need to have a third variable idx3 where idx3=
1
2
3
4
5
NB. idx1 and idx2 are linear indices and idx3 is the indices having all idx1 and idx2

Best Answer

  • If idx1 and idx2 are row vectors you can do
    idx3 = [idx1 idx2];
    If they are column vectors do
    idx3 = [idx1; idx2];