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.
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.
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:
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.