I hope you are doing well.
I am new to MathCAD and am trying to solve simultaneous equations using the least-squares method, however, every time I input the equations the variable is not recognised, even when I state the values one by one.
I am attaching my work. If you help me it would be much appreciated.
Solved! Go to Solution.
There's a couple of issues with your sheet. No worries, that is to be expected for a beginner.
Prime complains that xi is unknown. You did not define it. Well you say: But I defined x1, x2, etc...!
In (Mathcad and) Prime there is a BIG difference between an index and a subscript.
You get an index to x if you type "x" followed by a "[" then an integer (number). This will allow you to index (point to) individual elements of the array x.
A subscript is just an extension of the name of a variable, you get vs by typing "v" then [CTRL _] then "s".
You should also know that indexes start at 0 by default, governed by the built-in variable ORIGIN
somewhere on the sheet, and you'll see what it is.
You're trying to index x with i, which you defined at the top of the page from 1 to 9. However you've put and = at the end of the definition, to evaluate the range, and see what it has become.
Learn that you should NEVER evaluate a definition. It works, many times, but it causes lots of problems ever so often.
In this case (evaluation of a range) it causes the range to become an array. That's an undocumented feature (NO: nuisance) of Prime.
I will not correct your sheet (I've got other things to do, and you want/need to learn). Go ahead and make necessary changes yourself, and come back here if you run into new problems. You will get help here.
Luc, thanks a lot for your reply, it was much appreciated. I have corrected my mistake, however, I still have some issues.
What I did is to change the subscripts by indexes in every variable, and also changed my x into an array, mainly because when I tried to input x1, x2, and x3, etc with indexes it says I was overwriting an existing value. Nevertheless, I proved and it says no solution has been found. I do not know whether it has to do with my x as an array or anything else. I know I must have an answer because I am debugging the worksheet using an example from a book.
Great correction! You're a quick learner.
Find() tries to find the values of its parameters such that the equations are (perfectly) fulfilled. I suppose you did not expect find c, g and m values would exactly model your curve.
Check out the function minerr() instead of find()....
Yes, I have checked with minner() and gave me some values. However, I wonder why in the example of the book they use find () instead?. I am attaching it as well. Many apologies for the inconvenience
Welcome to Prime.
Do not type in square brackets as that means you are creating a matrix. Only type in curved brackets unless your intent is to create a matrix..
Here is the difference:
Does not solve the problem but it will go a long way to helping.
That's awesome, somehow my worksheet is not giving those values, I will revise yours and try to find the issue. Your help is so much appreciated!