I am trying to concatenate an array of numbers from 1->(a-1) + (a+1)->n.
I was using the cat function
cat(2, 1:a-1, a+1:n)
but I am getting the error
Index exceeds matrix dimensions.
Unless I am completely mistaken, I am just trying to concatenate two matrices of numbers so I'm not quite sure why I'm getting this error.
I'm trying to accomplish this:
>> a = 3;
>> n = 10;
>> cat(2, 1:a-1, a+1:n)
ans =
[1,2,4,5,6,7,8,9,10]
Is this the wrong way to do it? Any idea why this error is coming up?
Do you have a variable called cat in your workspace?
>> cat(2, 2:3, 4:6) # this works fine
ans =
2 3 4 5 6
>> cat = 1:3; # introduce the variable 'cat'
>> cat(2, 2:3, 4:6) # now it breaks
??? Index exceeds matrix dimensions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With