Community Tip - Want the oppurtunity to discuss enhancements to PTC products? Join a working group! X
Hello,
I'm setting up a Mathcad document for electronic circuit project.
I need a variable wich value are not continuos, but discrete: resistors for example are not avaible in alla value .. so I decalred a vector with the possible value of the resistors in the market:
10 12 15 18 22 27 33 39 47 56 68 82 100 120 150 180 220 270 330 390 470 560 680 820 1000 1200 1500 1800 2200 2700 3300 3900 4700 5600 6800 10000 12000 15000 18000 22000 27000 33000 39000 47000 56000 68000 100000 120000 150000 180000 220000 270000 330000 390000 470000 560000 680000
How can I declare a new variable with only this possible value?
I'd like to try a solution block to minimize and maximize a value of a voltage splitter (Vsplit = (V1/(R1+R2))*R2), but the resistor value must be one of the market value.
Thankyou
1. Upload a worksheet with what you've done so far, rather than have others type all the numbers in.
2. To maximise Vsplit for a given V1 it looks like you should choose the smallest value of R1 with the largest value of R2. Similarly, to minimise Vsplit, choose the largest value of R1 with the smallest R2.
Alan
Mathcad 15 or Prime?
Yet another reason for posting a worksheet along with a question whenever possible.
There is no way to restrict a variable to a set of values (unfortunately there is no such construct as a set in Mathcad, just vectors). Unless the problem is fairly easy to see what values to take (like the points Alan had posted) you would have to write your own routine which cycles through all possible values to find what you are looking for. Even more trouble if you add tolerance.
Just found that some months ago you had a similar question concerning tolerance values and you used Prime Express 2 at that time.
You could use the findExtrema() routine I provided here http://communities.ptc.com/message/199660#199660 and feed it with your vector of values instead of R1 and/or R2 which were resistance vectors, too, created by tolVec() [see below].
If you wish to combine your list of restistances AND tolerance, it should be not so hard to rewrite tolVec() to take vector arguments instead of scalars, if you are interested.
BTW, the following is what Alan was talking about (I didn't bother entering the full list)
The unit Volt at the end of vector V is wrong, its a Prime bug. It belongs to the min and max values (0.001 and 23.999) only.
You may have noticed that error already in the last thread (shame on me - I hadn't).
Another way to solve the problem, without using the SolveBlock.
Federico Manfrin wrote:
I need a variable wich value are not continuos, but discrete: resistors for example are not avaible in alla value .. so I decalred a vector with the possible value of the resistors in the market:10 12 15 18 22 27 33 39 47 56 68 82 100 120 150 180 220 270 330 390 470 560 680 820 1000 1200 1500 1800 2200 2700 3300 3900 4700 5600 6800 10000 12000 15000 18000 22000 27000 33000 39000 47000 56000 68000 100000 120000 150000 180000 220000 270000 330000 390000 470000 560000 680000
How can I declare a new variable with only this possible value?
So, the variable is already declared; it is the vector. I assume that this is one of the Rs (say R1); then R2 must take the same values as R1.
Consider V1 a constant.
Now, if R1 and R2 are introduced in the Vsplit function and evaluated, a matrix (n x n) representing the values of Vsplit is obtained. And the minimum / maximum value can be selected, and from its 'address', the corresponding (discrete) values of R1 and R2 are also obtained.
And the solution found must be as given by Alan / Werner.
Now, if R1 and R2 are introduced in the Vsplit function and evaluated, a matrix (n x n) representing the values of Vsplit is obtained.
Unfortunately not! If you put two vectors R1 and R2 into a function Vsplit (and you would have to use vectorization) you will only get a vector of the same dimension n as a result. Only the k-th element of each of both vectors would be combined.
So you would have to write your own routine to combine every value from one vector with every value of the other to get your n x n matrix to look for the extrema.
This is basically what my function findExtrema() from the aforementioned thread does, but more general in as much as it would take an arbitrary function and and arbitrary number of variables (vectors or scalars) to cycle through.
After all this brute force method of an exhausting search is limited by the number of combinations as it will take too much time with more variables and larger vectors . In this case we would have to resort to more intelligent algorithms and Richard once suggested simulated annealing (http://communities.ptc.com/message/208841#208841)
Werner Exinger wrote:
If you put two vectors R1 and R2 into a function Vsplit (and you would have to use vectorization) you will only get a vector of the same dimension n as a result. Only the k-th element of each of both vectors would be combined.
What I mean is:
R1 (i) = 10, ... 680000; i = 1... number of R1 values
R2 (j) = 680000, ... 10; j = 1... number of R2 values
Then, evaluate the function: V_split (i,j) = Vsplit (R1(i),R2(j)).
Is this going to work?
Is this going to work?
Why didn't you try it?
I think the way you sketched it should work (no need to reverse the order of R2, I would use the same vector twice). You would then use "max" or "min" and "match" to get the resistance values needed.But the method is limited to functions with a maximum of two variables and is somewhat inefficient as we only need one or two values from a rather big result matrix, which could be a problem with (much) larger input vectors. Just think of adding tolerance - 57 values, each with a spread of, lets say just 100 values to cope with tolerance. That alone would mean a 5700 x 5700 result matrix. And now think of more R values, more parameters and a fineer grid of values to catch up with tolerance.
Nevertheless what you proposed is quickj and nice way to solve Federico's problem with the voltage splitter. I'm not sure if this was just a simplified example or if its the real problem he has to solve. In the latter case I would resort to Alan's "method" 😉
Werner Exinger wrote:
I think the way you sketched it should work (no need to reverse the order of R2, I would use the same vector twice).
No need to reverse indeed.
Nevertheless what you proposed is quickj and nice way to solve Federico's problem with the voltage splitter. I'm not sure if this was just a simplified example or if its the real problem he has to solve. In the latter case I would resort to Alan's "method" 😉
Thank you. The proposal is to be used for this specific problem (2 var)... which is somehow close to Alan's method .
Werner Exinger wrote:
This is basically what my function findExtrema() from the aforementioned thread does, but more general in as much as it would take an arbitrary function and and arbitrary number of variables (vectors or scalars) to cycle through.After all this brute force method of an exhausting search is limited by the number of combinations as it will take too much time with more variables and larger vectors . In this case we would have to resort to more intelligent algorithms and Richard once suggested simulated annealing
No doubt about these algoritms (findExtrema, simulated annealing)... but in this case, by simply varying R1 and R2 and calculating the Vsplit for each i,j combination, the extrema is easily found.
I have the feeling that Alan did this by simply looking at the function and the values or R1 and R2, without using any algoritm.
I have the feeling that Alan did this by simply looking at the function and the values or R1 and R2, without using any algoritm.
Sure he did - simply asking what should happen to nominator and denominator so that a fraction is getting a maximal or minimal value 😉
And as I guess that Federico knows that, too, I supposed that he is after something more complex at the and - but then I may be wrong. We don't even know if its really Vsplit which has to maxi/minimized, we don't know if Federico is still using Prime, ... Don't know why he has marked a posting as helpful but didn't further elaborate on what is is he wants to achieve. Maybe he aleady lost interest.
And I agree that for functions with two parameters and vectors with double or even triple digit dimensions your suggestion is an easy way to get whats wanted.
Werner Exinger wrote:
I supposed that he is after something more complex at the and - but then I may be wrong. We don't even know if its really Vsplit which has to maxi/minimized, we don't know if Federico is still using Prime, ...
I truly understand your point. And if he is after something more complex, then... he needs more than my suggestion.
And I agree that for functions with two parameters and vectors with double or even triple digit dimensions your suggestion is an easy way to get whats wanted.
Thank you.
So lets wait if Federico will show interest again and reveal what it is he wants to achieve.
Maybe Federico is after something like in the attached.
With only a single criterion (ratio) and 2 resistor values, there is no task for Given/Find, Minerr etc. But fortunately the search is limited by range.
Success!
Luc
Thankyou LucMeekes, I'm working on your file!
Federico,
It's good to know that it's usable.
I'm interested to see what sort of thing you're actually accomplishing with it.
Can you show some results, if/when you have them...?
Success!
Luc
Hi Luc,
I'm still working on the file, without result because that file was for an old project, so I work on only for learning, and time is not so much ..