cancel
Showing results for
Did you mean:
cancel
Showing results for
Did you mean:

## Solving 2 simultaneous equations. There are 4 variables. 2 of these variables are to be determined by Mathcad. The other 2 variabes are defined as (a,b). A large set of (a,b) is provided.  1-Newbie

## Solving 2 simultaneous equations. There are 4 variables. 2 of these variables are to be determined by Mathcad. The other 2 variabes are defined as (a,b). A large set of (a,b) is provided.

Hi! I am trying to solve 2 equations simultaneously.
There are 4 variables (x,y,a,b) in these 2 equations. 2 of these variables (x,y) are to be determined using Mathcad.

The other 2 variables (a and b) are given, However there is a large set of values of 'a' and 'b', around 1000!
If it was only 2 set i would have replaced the values of 'a' and 'b' each time, then take the solutions for (x,y).
However replacing 'a' and 'b' 1000 times doesn't seem a good idea!
I was wondering if there is a way in Mathcad to define 'a' and 'b' as arrays of values and then solve for x and y. So as to obtain the solution for all pairs of (a,b) at one go.
Thanks for helping!

1 ACCEPTED SOLUTION

Accepted Solutions  24-Ruby V
(To:ptc-5403048)

The solution is to turn the solve block into a function of a and b and all this function (vectorized) with two data vectors as argument.

If these data vectors are not of the same dimension and you want to solve for every combination of values from the two vectors, then a small program routine would be necessary.

See if the attached would help.

Vectorization is not really necessary in case of your equations, but is used here just to be on the safe side.

At the end of the sheet you find a different approch using symbolics, which gives you both pairs of x/y for every a/b. The solve block will only give you one, depending on the guess values you provide and/or additional constraints.

4 REPLIES 4  24-Ruby V
(To:ptc-5403048)

The solution is to turn the solve block into a function of a and b and all this function (vectorized) with two data vectors as argument.

If these data vectors are not of the same dimension and you want to solve for every combination of values from the two vectors, then a small program routine would be necessary.

See if the attached would help.

Vectorization is not really necessary in case of your equations, but is used here just to be on the safe side.

At the end of the sheet you find a different approch using symbolics, which gives you both pairs of x/y for every a/b. The solve block will only give you one, depending on the guess values you provide and/or additional constraints.  1-Newbie
(To:Werner_E)

Thanks Werner. It was very helpful indeed!
There's only 1 hiccup now. The values for 'a' and 'b' are provided in an Excel sheet.

In a_vec:=stack(15,36,50,55), i'll have to enter each of these data manually. Is there a way i can copy the data from the Excel sheet directly into Matcad? Normally i wouldn't mind doing it manually but since there's a really large data set, it going to take me hours!

I'm sending you part of the Excel sheet. I'll be really grateful if you could help me. Thanks!  24-Ruby V
(To:ptc-5403048)

There are at least four different ways how you can get your data into Mathcad.

1. The least desirable method - copy from Excel to a vector or matrix in Mathcad. Select the a-values in Excel, press Ctrl-C, goto Mathcad, type a: and then press Ctrl-V. Advantage: The Mathcad sheet is self contained and will work without the Excel sheet being present. Disadvantage: If tha data changes, you get a different Excel sheet, you have to copy and paste again
2. The method I'd prefer. Use the READEXCEL function of Mathcad to read in the selected data.
a:=READEXCEL("Problem.xlsx", "A2:A9), etc. The sheet has to be in 2007 format (xlsx). If its in 2003 format (xls) you should use READFILE with filetype "excel" instead.
3. Use "Insert/Data/File Input/File Format: M\$ Excel" ...
4. Use "Insert/Component.../M\$ Excel/....

P.S.: There is nothing wrong at using Mathcad's built-in help system  5-Regular Member
(To:Werner_E)

Further to Werner comments I would highly recommend using one of the file input options. I have passed many worksheets to the forum in the past which will help. I will try and find them and post for information. 