I want to fit with minerr a sinus function. The sampled xy-dataset consists of e.g 20 periods of a sinus signal. I want to know the period (time of oscillation) of each of the 20 periods. In a loop I want to fit with minerr the data. How can I do it? I attached the data-file and the mathcad 15 document with with the programming I've done so far (just look at the red marked boxes).
what do you expect to get with (F(as,X) - Y)^2 ? If you want these to matrices to be (as) equal (as possible), you would have to write F(as,Y)=Y instead.
Q(Y)= gives you a 4x1 vector with values slightly different from the start value as. Q(D) gives you still an error because the way you have written it Q is a function with a 500x20 matrix as the argument, D is a 500x1 vector - the dimensions simply do not match.
Y is and F returns a 500x20 matrix, the difference is a 500x20 matrix, too.
You can not square a non-square matrix and thats why Mathcad delivers the error message "This matrix must be square" when you try to use Q (a function you assigned minerr to) the first time.
Turn the solve block into a function, and call the function in a loop.
If you are minimizing a vector of residuals make sure mineer is using the LM algorithm.