Community Tip - Stay updated on what is happening on the PTC Community by subscribing to PTC Community Announcements. X
Hello All
I am new to Mathcad and I am currently trying to use function solve blocks but i am getting an error that says initial guesses must consist of numbers and matrices. I am not able to figure out where I am going wrong and how to rectify it.I have enclosed my worksheet
Solved! Go to Solution.
Vishniu Gopalakrishnan wrote:
Hello All
I am new to Mathcad and I am currently trying to use function solve blocks but i am getting an error that says initial guesses must consist of numbers and matrices. I am not able to figure out where I am going wrong and how to rectify it.I have enclosed my worksheet
The good news first: You have used the solve blocks perfectly correct and you also turned them into function without any error.
If you really need all those constants and guess values as arguments of your function you can do exactly like you have done.
The error occurs because in your program you have in the last line T[i <-- N[8. This line turns T into a nested vector of values but your solve block expects T to be a scalar or at least a matrix consisting of just scalars. The error message is misleading here and in no way helpful. So you have to change your routine so that the last argument in the call of sol2 is a scalar (probably the last value in vector T.
Maybe you don't even need to make T (and also theta.2,3,4) vectors? The value in one iteration might as good overwrite the previous one, unless of course you need all values as result. You have not yet decided what the routine should return as rsult for torque. As you have it now it would be the last value N[8 because thats the last assigment made.
The error in greater detail:
While looking at your sheet I found an irregularity which I think applies for a Prime bug. Maybe someone can look over it and report them to PTC support (I won't do so) if appropriate.
I suggest you look up Solve Blocks in the help menu.
You must provide guess values for all unknown variables. The number of equations in the 'constraints' section of the solve block must equal the number unknown variables.
Thank you for the reply Mike.I have a few questions
1.Is it possible to pass guess values as an argument?or do I need to explicitly mention it in the solve block?
2.In the program, A & C are not guess values but actual values that need to be used in the computation and it changes for every interation in the program.Does mathcad recognize that it is that and not a guess value?
Vishniu Gopalakrishnan wrote:
Thank you for the reply Mike.I have a few questions
1.Is it possible to pass guess values as an argument?or do I need to explicitly mention it in the solve block?
Yes you can. Have a look at the attached worksheet for a VERY simplistic example of passing a function to a solve block.
Vishniu Gopalakrishnan wrote:
2.In the program, A & C are not guess values but actual values that need to be used in the computation and it changes for every interation in the program.Does mathcad recognize that it is that and not a guess value?
They can be defined outside the solve block if they need to be used in proceeding calculations.
Thank you so much Mike. I will go through it and will get back if I still have any doubts
Vishniu Gopalakrishnan wrote:
Thank you so much Mike. I will go through it and will get back if I still have any doubts
No problem at all.
Vishniu Gopalakrishnan wrote:
Hello All
I am new to Mathcad and I am currently trying to use function solve blocks but i am getting an error that says initial guesses must consist of numbers and matrices. I am not able to figure out where I am going wrong and how to rectify it.I have enclosed my worksheet
The good news first: You have used the solve blocks perfectly correct and you also turned them into function without any error.
If you really need all those constants and guess values as arguments of your function you can do exactly like you have done.
The error occurs because in your program you have in the last line T[i <-- N[8. This line turns T into a nested vector of values but your solve block expects T to be a scalar or at least a matrix consisting of just scalars. The error message is misleading here and in no way helpful. So you have to change your routine so that the last argument in the call of sol2 is a scalar (probably the last value in vector T.
Maybe you don't even need to make T (and also theta.2,3,4) vectors? The value in one iteration might as good overwrite the previous one, unless of course you need all values as result. You have not yet decided what the routine should return as rsult for torque. As you have it now it would be the last value N[8 because thats the last assigment made.
The error in greater detail:
While looking at your sheet I found an irregularity which I think applies for a Prime bug. Maybe someone can look over it and report them to PTC support (I won't do so) if appropriate.
Thanks Werner for the detailed expanation.I corrected it and it now works fine
Vishniu Gopalakrishnan wrote:
Thanks Werner for the detailed expanation.I corrected it and it now works fine
You are welcome! Glad it works for you now.