Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

** Community Tip** - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn!
X

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

May 17, 2022
02:56 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

May 17, 2022
02:56 PM

Calculating a value using normal equations

Dear All,

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.

Labels:

1 ACCEPTED SOLUTION

Accepted Solutions

May 17, 2022
06:49 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

May 17, 2022
06:49 PM

Hi,

If you choose the guess values in the supplied pdf you get a solution just as in the example.

11 REPLIES 11

May 17, 2022
04:58 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

May 17, 2022
04:58 PM

You should attach your Prime worksheet (.mcdx file). Not just a picture.

Success!

Luc

May 17, 2022
05:00 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

May 17, 2022
05:00 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

May 17, 2022
05:15 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

May 17, 2022
05:15 PM

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

Type

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.

Success!

Luc

May 17, 2022
05:51 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

May 17, 2022
05:51 PM

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.

May 17, 2022
06:00 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

May 17, 2022
06:00 PM

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()....

Success!

Luc

May 17, 2022
06:09 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

May 17, 2022
06:09 PM

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

May 17, 2022
06:40 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

May 17, 2022
06:40 PM

Hi,

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.

May 17, 2022
06:49 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

May 17, 2022
06:49 PM

Hi,

If you choose the guess values in the supplied pdf you get a solution just as in the example.

May 17, 2022
06:53 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

May 17, 2022
06:53 PM

Dear Terry,

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!

May 18, 2022
12:04 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator