MATLAB: How to fix gradient descent code

gradient descent

I am a novice trying to do a gradient descent with one variable, but cannot figure out how to fix my code (below). Not sure if my for-part is correct. This is the error message: "In an assignment A(:) = B, the number of elements in A and B must be the same." Please help?
data = load('data.txt' );
X = data(:, 1); y = data(:, 2);
m = length(y);
X = [ones(m, 1), data(:,1)]; % Add a column of ones to x
theta = zeros(2, 1); % initialize fitting parameters
num_iters = 1500;
alpha = 0.01;
J = computeCost(X, y, theta)
m = length(y);
J = sum(( X * theta - y ) .^2 )/( 2 * m );
[theta J_history] = gradientDescent(X, y, theta, alpha, num_iters)
J_history = zeros(num_iters, 1);
for iter = 1:num_iters
h=(theta(1)+ theta(2)*X)';
theta(1) = theta(1) - alpha * (1/m) * h * X(:, 1);
theta(2) = theta(2) - alpha * (1/m) * h * X(:, 2);
% Save the cost J in every iteration
J_history(num_iters) = computeCost(X, y, theta);
end

Best Answer

theta(1) - alpha * (1/m) * h * X(:, 1)
and
theta(2) - alpha * (1/m) * h * X(:, 2)
are 2x1 vectors which are assigned to scalars in the lines
theta(1) = theta(1) - alpha * (1/m) * h * X(:, 1);
theta(2) = theta(2) - alpha * (1/m) * h * X(:, 2);
This is not possible.
Best wishes
Torsten.