Community Tip - Have a PTC product question you need answered fast? Chances are someone has asked it before. Learn about the community search. X
Hi all, I have a question regarding the selection of a proper value for a parameter from a list based on the evaluation of its transfer function.
As shown here, if I have a variable a, whose value can be selected from a list. A transfer function TF(s,a) is an s-domain function including this variable. We can calculate bandwidth and phase margin of a selected value of "a". I am wondering if it is possible to specify the criteria for the bandwidth and phase margin, and let Mathcad follows these criteria and select the optimized value of "a" from the list?
Thank you!
Solved! Go to Solution.
I've extended the ranges of a, b and c values to 9 values each, and made a few changes to the code to allow it to deal with imaginary numbers.
It takes a little while to calculate all 729 results, but you've got something to choose from !
Success!
Luc
See if the attached file helps-
Hi Werner, thank you for much for your help! Your solutions works well. Now can I ask for a more complicated scenario, by extending the numbers of variables to 3? Thank you!
In this case, if you continue the brute force way of trying all combinations, you would make TF a function of b an c as well -> TF(s,a,b,c):=...
The pickValue routine would have three options as arguments (one for a, b and c) and instead of the one for loop you would use three nested for loops (for a-options, b-options and c-options) and innermost again the same statements which calculates BW_OK and PM_OK and jumps out at the very first fitting combination found.
Something like this...
Now lets put in the data:
And the result is (1st column holds the a values, 2nd column the b-values, 3rd column the c values
Then 4th column the fBW values, 5th column the Fu values and the 6th (last) column the phase margins):
Take your pick.
Oh, mind. There are some imaginary frequencies. A good pick might be No 20:
Success!
Luc
Thank you LucMeekes! I though your solution provides all the calculated BW&PM for each combination. If I am using your code, would you teach me how to return the optimized a,b, c based on the evaluation of the calculated BW*PM results? Thank you!
Hi LucMeekes,
I am using your solution plus the method provided by Werner to search the right solution, but I got some problems. Would you teach me how to solve it?
In my real case, I am use a 15 options parameter "C1" and 16 options parameter "R2", and I am able to calculate all the BW and PM in each case for matrix "Data" (it is a 240x4 matrix).
What I tried to do it is to find the raw index number "x" of data matrix, when BW and PM can meet the requirement.
However, it seems like I am not able to return the index number, while the error message showed "this value must be a vector".
Would you tell me what is wrong with my code? Thank you!
I've extended the ranges of a, b and c values to 9 values each, and made a few changes to the code to allow it to deal with imaginary numbers.
It takes a little while to calculate all 729 results, but you've got something to choose from !
Success!
Luc
Heres the modified version for my brute force attack which stops at the first fit.
Encounter a floating point error.
have no time to look at at the moment - maybe later
Thank you Werner! I can solve my problems now using Luc's method.