Community Tip - Did you get an answer that solved your problem? Please mark it as an Accepted Solution so others with the same problem can find the answer easily. X
Help!
I am trying to solve a set of simultaneous equations (25 variables) and I am not getting the results I am expecting. I have compared my MathCAD solution to bothe actual results and a PSPICE simulation.
I have distilled my problem to a much simpler example which I have enclosed and I cannot determine why the results do not match.
I have respresented the circuit as a simbple resitsor divider then added a simple low pass filter. With a frequency of 0 Hz (s=0) or a DC operationg point, I have represented the capacitors as an open circuit (Rcap = 1 / C*s). Since there is no current through RR3 or RR4, I know the results should be the same but with only RR3 in the equations, the results work, but when I add RR4, the results do not match.
Solved! Go to Solution.
Why do you use a program? It is not a function. You cannot see results!
The use of a function is just the nature of my final analysis. Since I will be running a Monte Carlo analysis (10,000 iterations), it is easier to put this into a function. Guess the next time I will just use equations first then place into function after I am satisfied with the results.
You have a sign wrong! C3 should be negative.
Alan
Alan,
Guess I was too close I did not see it. Now all I have to do is find the wrong sign in my complex analysis.
Thanks
Wouldn't a solve block (avoiding error-prone manual rearranging of expressions) be more convenient?
The solve block actually would work better to avoid errors but, I need my solution in the form of a function. I am running multiple types of analysis on the same function (including a 10,000 interaction Monte Carlo analysis and I only want to make changes in one place). I have not be able figure out how to put a solve block into a function. Any ideas?
Also, I do not know if the "Find" function has the same limitation of passing parameters to it as I have found on passing parameters to a function. My final analysis has 25 variables and I get errors if I try to pass more than 21 variables to my function. I have substituted an array passed to my function which works fine so I should be able to re-write the equations using an array vs. to individual names.
I have not be able figure out how to put a solve block into a function. Any ideas?
Yes, you can do it that way (without defining the RRx beforehand):
You may even use the symbolic solve (this time the RRx are defined before, but thats not mandatory. You can write it as above as a function.
Sorry, German Version - "auflösen" is "solve".
Also, I do not know if the "Find" function has the same limitation of passing parameters to it as I have found on passing parameters to a function. My final analysis has 25 variables and I get errors if I try to pass more than 21 variables to my function.
That could indeed be a problem, even if you would turn the RRx and Vxy into a vector. Unfortunately neither the solve block nor the symbolic solve would allow to solve for a vector whose single elements are used in the equation. So you would have to type V[0, V[1, .... and while I don't know I would guess that the same restriction as with the argument list of functions would apply. You would have to try it out.
Gave me some good ideas. See attachment.
Looks like I will not be able to use the "solve" function (f_CC) for it looks like it solves the problem once and is not modifiable. The "find" function works fine (f_CC1, f_CC2 and f_CC3).
The only problem is how to set the vectors to variables instead of hardwiring them to specific locations.
In f_CC2 the equations become unreadable while f_CC3 is readable.
Now, if I change the input vector of variables, then I will have to go change the function as well.
In f_CC4 and f_CC5, I have created look up functions to find the variable location in a matrix, unfortunately the "Given" function does not work. I get "pattern match exception" error.
Looks like I will not be able to use the "solve" function (f_CC) for it looks like it solves the problem once and is not modifiable.
Think this is only because you used RRx in your equations there instead of Rx.
In f_CC4 and f_CC5, I have created look up functions to find the variable location in a matrix, unfortunately the "Given" function does not work. I get "pattern match exception" error.
There is a built-in function which basically does the same as your f_lookup. It calles vlookup and you would use it like vlookup("Vin", Comp, 1)[0
I am not sure if its the solve block per se which is not happy with the lookup or if it has to do with the symbolic evaluation of Find. You could try to omit that but then you would have to provide guess values for all variables solved for.
I think that lookup function is introduced by you to be able to deef the function f_CC4 with a vector to circumvent the limit of 21 you had written about. But I guess you will find tnat the same limit apllies to Find and you cannot solve for the vectors there.
I intended to include a worksheet with some attempts, but Mathcad continues to crash without letting me save first
Edit: Your f_lookup2 ressembles the built-in command "match".
Since the equations are linear, why not solve them as in the attached? (Unloaded example only).
Alan
This would work well if it the analysis was so simple. See attachment. I have 25 equations for 25 unknowns and 52 input variables.
When I run a Monte Carlo analysis (of n iterations) I create a matrix of input variable (w/ n entries each), then just call the function n times using the input variable matrix. I can then figure out the distribution and calculate statistical parameters.
If you look at my response to the above report I have a solution but it does make the up-keep high. If I modify the input variable matrix, I have to update the solution function each and every time.
Thanks,
Very helpful and some useful aproaches.
Too bad my equations seem too complex for "solve" to handle it. After 6 hours it just crashes.
I am now trying to work with "find" now, but still churning after 2 hours. Little hope.
Guess my intial estimate to find my initial missing sign error will have to do.
Also, thanks to all those who responded.
John Tesko wrote:
Thanks,
Very helpful and some useful aproaches.
Too bad my equations seem too complex for "solve" to handle it. After 6 hours it just crashes.
I am now trying to work with "find" now, but still churning after 2 hours. Little hope.
Guess my intial estimate to find my initial missing sign error will have to do.
Also, thanks to all those who responded.
The solutions with "Find" which where in game so far all used the symbolic evaluation. maybe it would help and speedup if you used the numeric evaluation. In that case you would have to provide guess values for the solved for variables above the solve block.