cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - When posting, your subject should be specific and summarize your question. Here are some additional tips on asking a great question. X

Problem using variable defined in solve block

bcoppola
4-Participant

Problem using variable defined in solve block

Hello,

I am having a problem using a variable after it was defined with a solve block with the find command. It seems like the variable is assigned correctly, but when I try and use it later in the sheet in another solve or find command it gives me an undefined variable error. The error traces back to the assignment on the variable in the original solve block. Please see attached.

Thanks

8 REPLIES 8
MikeArmstrong
5-Regular Member
(To:bcoppola)

Because the symbolic processor doesn't understand units.

Mike

Also, why are you trying to solve symbolically?

You have theta and theta1 as unknowns in the final equation.

Mike

I know I just need to rearrange the equation and it would work, I am just trying to understand the problem so I don't have it again in the future. It's sometimes hard to troubleshoot in mathcad, at least I think so, so I try to figure out what is causing different problems as I come across them.

So the symbolic solver gets confused with units? I knew that was the case for the ODE solver but I thought it was alright for other solvers.

Thanks

MikeArmstrong
5-Regular Member
(To:bcoppola)

Copied from the help menu.

Mathcad treats units as undefined variable names in symbolic calculations. It does not combine units of the same quantity unless they are the same unit, that is, m + m → 2m, but m + cm → m + cm.

If you pass an expression with units to a symbolic function that expects only numbers, Mathcad returns an error.

Mike

So why doesn't the error show up until I try to use the variable later? It seems like it "finds" and everything gets assigned correctly, until I try to use the variables (a3 and a4) in the solve line later. If I reassign the variables the solve functions works. In other words, if I put a3 := 13.114in and a.4 := 1.258in just before the line that is giving an error, it will solve with no problems. How is this different from what is already stored in variables a3 and a4 from the find function?

Also note that a1 and a2 don't cause a problem. Both of those variables have units but they don't return an underfined variable error.

MikeArmstrong
5-Regular Member
(To:bcoppola)

Brian Coppola wrote:

I don't understand why that is happening, but look at the examples below. 1 with units and one without.

Clipboard01.jpg

Mike

Ya, I had noticed the unit thing when I was messing around with it. I was more curious about the error from the "undefined variable" though. Just seems really odd to me that it only has a problem with the two variables coming out of the previous solve block. When you do a trace it runs right back to the solve block too. Any ideas?

MikeArmstrong
5-Regular Member
(To:bcoppola)

Ya, I had noticed the unit thing when I was messing around with it. I was more curious about the error from the "undefined variable" though. Just seems really odd to me that it only has a problem with the two variables coming out of the previous solve block. When you do a trace it runs right back to the solve block too. Any ideas?

Sorry of course. It must have something to do with the results coming from the numerical processor. Try putting mu in the symbolic solution and that will also fail. The other variables are passing to the symbolic processor because the units associated with them are treated as undefined variables.

If you are doing symbolic calculations (the only kind that can be done with undefined variables. So basically when you are redefining after the solve block, you are in fact undefining for the symbolic processor. (I think)

Symbolics isn’t my strong point to be honest, other members know a lot more than me.

Top Tags