Hi,
I have a matrix a (see below). I would like to replace the 1st and 3rd row with the same row vector [255 100 0].
a = 245 255 255 254 252 255 251 250 239
Initially I created an index variable 'idx'
idx = [1;3]; % indexing row number for vector replacement
However
a(idx,:) = [255 100 0 ];
would give error messages
'Unable to perform assignment because the size of the left side is 2-by-3 and the size of the right side is 1-by-3'.
How to do it correctly without do it in a loop?
Best Answer