The PTC Community is on temporary read only status in preparation for moving our community to a new platform. Learn more here
Attempting to use a range to help determine a solve block but am struggling to get this function to work. Any ideas on how to debug this issue? See attached image.
Hi
It is better to include the worksheet not an image.
Necessary to put the worksheet in a zip archive file to upload it.
Which version of Prime are you using?
First
c1 is a range not a vector variable
Why did you define c.1 as a range and use it later in the solve block?
Why did you try to use a range as a guess value for the variable c.12 the solve block is supposed to provide a solution for?
Definitions (using := ) should be placed outside and in front of the solve block.
Assign c.12 a constant (guess) value like c.12 := 20 mm and see if Prime can find a solution.
As it looks you are just looking for the (a) zero of function g.
You may also use the "root" function for this, but you would not be able to apply additional constraints when you do so.
Guess that for further help you would have to post the worksheet (and say, which version of Prime you are using).
Here is how to declare vectors and use them in a parametrized solve block repeatedly.
Thanks both,
Do apologise for not attaching the Mathcad sheet in the first place, see attached.
The issue I am trying to resolve is on page 34 of the attached.
I am working with Mathcad Prime 10.
Kind regards,
Variable and function definitions are better done outside and in front of the solve block.
The solve block on page 34 fails because with a guess of 38,1 mm the solution for which Mr(c11)>0 cannot be found by the algorithm used in Prime.
If we deactivate this constraint we get a solution.
If we use a larger guess value, we get the second solution for which M.r>0
Here you see the plot of function g along with its two zeros at 38.8 mm and 325.0 mm
It can be clearly seen that Mr is positive at the second zero.
Zooming in shows that Mr is negative at the first zero:
Prime 10 sheet attached.
BTW, when posting a worksheet for a question to be answered, its preferable to limit it to the necessary regions only so its easier to edit and clearer to see where the problem may be. I did not tamper the 34 pages in front, but at least I deleted the 100(!) pages after the relevant position.
Thank you very much both, I am also struggling to root the function on page 25 of the attached. Are you able to assist?
@IA_12699372 wrote:
Please ignore this request, I have got it working
Too late 🙂
But I see that you arrive at the same result as I did in my previous answer.
The 4-page-sheet you posted is just the kind of sheet you should post when asking a question. Showing only the vital calculations and not a 130+ page sheet which is nearly impossible to deal with.
Instead of
I would prefer
so that the resulting vector is just returned once at the end of the program AFTER the for-loop finishes.
You should test drive functions when you defined them!
Functions C.s and T.s never will evaluate and throw an error when you try to use them:
Reason is the vector index "k". Variable "k" is defined as a range (0;1) but must be a scalar integer.
The same problem also occurs in other function definitions you make!
If you expect a 2x1 vector as the result of these functions, you may either use a programmed for-loop
or you make the vectors used additional arguments of the function, treat them like scalar arguments and call the function vectorized with the vectors as arguments:
Another option, which you may like more, is to use vectorization already when defining the function:
But this does not work in all cases:
Reason in this case is the "min" function which is written to deal with vectors as well and so can't be vectorized.
A workaround could be to use a local auxiliary function which can be called vectroized:
If you make the other functions involved to work OK by whatever method, the root function will work as intended:
