>>50992397I'm so sorry. Arrays start at 1. 90% of my MATLAB bugs are me forgetting that. A lot of things that would need loops in other languages can be done in single commands. The colon and cell selections make things easier.
% A blank 2D matrix. 2 rows, 5 columns.
x = zeros(2, 5);
% Set all elements to 1. Colon means "all".
x(:) = 1;
% Add 1 to all rows the first column. There's no += in MATLAB.
x(:, 1) = x(:, 1) + 1;
% Add 1 to cells in the first row, and the second-to-fourth column.
x(1, 2:4) = x(1, 2:4) + 1;
You can also use a single number to reference a cell.
x(1); % First row, first column.
x(2); % Second row, first column.
x(3); % First row, second column, and so on.
x(:); % Spaghettify the matrix. Returns a single-column vector.
y = x(1:end/2); % Make y the first half of x.
Of course you can still use all the for-loops you wish (and sometimes you'll need to) but in a lot of cases, you can use clever selections to do it the job.