Hello,
I am trying to use a solve block to find values for two variables but am running into difficulties. It seems that I am always getting an error "variable is undefined". After searching the forum it seems this is the standard error from a solve block and doesn't really give any clue as to what I'm doing wrong.
I originally suspected that I was having issues since I was making use of functions with conditional statements, but after experimenting and removing the statements I am still not getting any results. Manually, I can come close to getting a solution.
Please see attached sheet. Thanks.
Solved! Go to Solution.
I don't think it's possible to handle the mixed units the way you are trying to do it. It tries to substitute unitless values into the equations, and just comes up with other unit errors. You need to assign the result to a vector with two variable names, and then evaluate each variable separately.
Sigma.n2 was not defined as a function of x. Also, x has no defined value. You also have two equations and one unknown, so there is no exact solution. That means you must use minerr, not Find.
Your force and moment are both linear functions of slope and will never satisfy both conditions of the solve block at the same slope.
It's not clear to me which two variables you're trying to solve for.
Richard and Fred, thanks for your responses.
I will attempt to clarify what is going on in the worksheet. This is used to calculate the bearing stresses under a footing. The sheet is a subset of a larger, more complicated one.
sigma is the value of the stress at a specific location under the footing. The footing starts at x=0 and goes to x=L.incl (the length of the footing). The width of the footing, B(x), will vary along the length so it is also a function of x.
For some distance, a crack will form from x=0 to some distance (x=L.crack), where the stress must be equal to 0, but the length of that crack is unknown.
Essentially I am trying to describe a triangle with a base length of (L.incl-L.crack) and a maximum height of (slope*(L.incl-L.crack)). At intermediate values of x between L.crack and L.incl, the base of the triangle to the left of x is (x-L.crack), and the height is (slope*(x-L.crack)). The value of sigma at x=0 should be 0, at x=L.crack should be 0, and at x=L.incl some number which I am trying to find.
So, the way it is set up, sigma is a function of x, with the slope being a constant. I need to find both the length of the crack (L.crack, to find the length of the base of the triangle), and the slope of the top of the triangle (to find the height of the triangle).
So, two unknowns, L.crack and slope. Two conditions: Area under sigma is = F.perp, and the moment under sigma is equal to M.
Doesn't the length of the crack change the CGx?
Set up as you describe, it still won't solve.
I don't think it's possible to handle the mixed units the way you are trying to do it. It tries to substitute unitless values into the equations, and just comes up with other unit errors. You need to assign the result to a vector with two variable names, and then evaluate each variable separately.
Neat!
Any time I've tried that I've gotten errors about mixed unit vectors."
Attached is an example of what I was trying to do (a solve block with mixed units.) (With asststance from yourself and JmG.)
Interesting. So I guess I was wrong abut why the one above does not work. I'll have to look at it again.
Edit: I don't know why it can't find a solution. The problem is that is simply does not converge, even if I set CTOL very large. I suspect it's something to do with the scale of the numbers when the units are removed.
Thanks, that seemed to work. But now I have a few questions:
1) When defining sigma, my thinking was that I was creating a function which x is the ind. variable, and slope and Lcrack are constants. ie f(x)=mx+b, and changing the value of the constants to get the function I want. In your example you have changed it so that f(m,x,b)=mx+b. Why does my way not work? I have used it for other sheets in the past where it worked fine. When I changed it back so that sigma was a function of only x, it no longer worked.
2) Before I explained my sheet further, you defined a value for x. Do I still need do that if I want a function that depends on x as the ind. variable? I removed that line from the sheet you posted and it still seemed to work.
3) I don't understand why when you store the results of Find into a vector it works, but when you try to display the results with an = after the command, it doesn't. I was under the impression that you can't have mixed unit vectors, but you seem to have done it in this example.
1) You didn't define a function for sigma, you defined an equality using the bold =. Then in the equalities with the integrals you called a function sigma(x), but that function does not exist. You can only create a function definition using the definition operator, :=
2) No, you don't need to define x. I'm not sure why I thought that was necessary
3) You can't have mixed unit vectors. The trick here though is that I am assigned one result to one variable, and the other result to another variable. So what I have is two scalars, not one vector. The vector of two variables on the LHS does not exist except visually on the page.
Thanks for the explanation. I understand what you are saying about operator, but my question was more about defining a function with a constant (or more specifically, and variable which I can change) and an independant variable, vs defining a function of two independant variables. I've figured out how to work around it though in the rest of my spreadsheet.
Thanks again for your help.
If you define f(x)=mx+b, then m and b are indeed constants (as an aside, m is a very bad choice, since it overrides the unit for meters, but that's another story). They are fixed at the point the function is defined, based on the last assigned values for the variables m and b before the function definition. They cannot be changed after that point whether by a solve block or any other means. The only way to change them after the function definition is to include them as arguments to the function.
That makes perfect sense, thanks again for the clear and helpful explanation!
In this case no, CGx will remain the same in order to properly calculate the overturning moments (not shown in the posted worksheet).