I am trying my array in a single dimension, but receive the error "Subscripted Assignment Dimension Mismatch". However, I am able to perform the same operation if I make a temporary variable first. Is there a way to do this without creating the temporary (y) variable? Even better, is there a way to do it without looping, by using an index vector?
Thank you.
x = zeros(2,5);
idx = [1 2];
% This doesn't work...
% x(idx,:) = [x(idx,:) 1];
% This doesn't work...
% for i=idx
% x(i,:) = [x(i,:) 1];
% end
% This works...
for i=idx
y(i,:) = [x(i,:) 1];
end
x = y;
x = [x ones(size(x,1),1)];- chappjc