Here's some MATLAB code that implements the idea in Claude Leibovici's answer.
First we generate some data
a = 10;
b = 2.5;
x = linspace(0, 2*pi, 200)'; % 100 points between 0 and 2pi
y = a * sin(b * x) + 10*randn(size(x)); % y = a sin(bx) + noise
which look like this

Now you define your objective function, which will be a function of b only (since we will choose a by least squares)
function [mse, a] = obFun(b, x, y)
sinbx = sin(b * x);
a = sinbx \ y; % choose a by OLS
err = y - a * sinbx; % compute error terms
mse = mean(err.^2);
end
Say you suspect that the true value of b is in the interval [0, 5]. Then you can create some values in that interval, and compute the mean-square error on each value.
bValues = 0.01: 0.01: 5;
for i = 1:length(bValues)
mse(i) = obFun(bValues(i), x, y);
end
The mean-square error as a function of b looks like this

So you can see that there is an obvious minimum near to 2.5. You can find out exactly where it is, and from that find out the optimal values of b and a.
[mseMin, j] = min(mse);
bOptimal = bValues(j);
[~, aOptimal] = obFun(bOptimal, x, y);
fprintf('a = %.3f, b = %.3f\n', aOptimal, bOptimal);
which results in
a = 10.548, b = 2.540
which are reasonably close to the true values of a = 10.0 and b = 2.5.